本帖最后由 lvlup200 于 2016-3-18 17:10 编辑
- class F {
- public static void main(String[] args) {
- Student a = new Student();
- a.setChinese(99);
- System.out.println(a.getChinese());
- a.setMath(108);
- System.out.println(a.getMath());
- a.setEnglish(106);
- System.out.println(a.getEnglish());
- System.out.println(a.getSum(a.getChinese(),a.getMath(),a.getEnglish()));
- }
- }
- class Student {
- private int chinese;
- private int math;
- private int english;
-
- public void setChinese(int chinese) {
- this.chinese = chinese;
- }
- public int getChinese() {
- return chinese;
- }
-
- public void setMath(int math) {
- this.math = math;
- }
- public int getMath() {
- return math;
- }
- public void setEnglish(int english) {
- this.english = english;
- }
- public int getEnglish() {
- return english;
- }
- public int getSum(int chinese,int math,int english ) {
- return chinese+math+english;
- }
- }
复制代码 错误地方有,打字打错的比如:Chinese,; 有没有加对象. 的 比如 a. 还有没有加参数的 ,比如 getSum();
|