看到的几个问题:
1、 public void seti(int i){
this.i = i;
}
这个类里面你定义int i 了吗? 没定义怎么this.i呢?
2、 public void setage(String name){
this.school = school;}
方法名字是setage 传的参数却是name,set的是school
,这方法里面你想set什么你自己清楚吗?
3、public class test{
student a = new student();
a.said("mark","fjnu","five");
}
}
最下面这个大括号的开始是class student{ 这个括号
这里你没必要写成类中类
4、class test 里面没得main方法,应这样写
package com.lch.show;
public class student {
private String name;
private String school;
private String age;
public void setname(String name) {
this.name = name;
}
public void setschool(String school) {
this.school = school;
}
public void setage(String age) {
this.age = age;
}
// public void seti(int i) {
// this.i = i;
// }
public String getname() {
return name;
}
public String getschool() {
return school;
}
public String getage() {
return age;
}
public void said(String name, String school, String age) {
System.out.println("我的名字叫" + name + "今年" + age + "岁");
}
}
class test {
public static void main(String arge[]) {
student a = new student();
a.said("XXX", "XXX", "123");
}
}
改了的地方你自己对比着看吧