我的class.java内容
package pkg1;
import pkg2.*;
public class myclass {
public static void main(String[] args) {
// TODO Auto-generated method stub
student stu = new student();
stu.getName("go");
}
}
contentof student.java
package pkg2;
public class student {
public int id;
String name;
int rollno;
int age;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getRollno() {
return rollno;
}
public void setRollno(int rollno) {
this.rollno = rollno;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
我想从myclass.java初始化pkg 2的student.java变量,但是它的显示字段不可见,我已经在pkg1 myclass.java中导入了pkg2的内容,并且还宣布了Student.java的成员函数为public
慕沐林林
相关分类