package Tom;
public class Student{
int number;
Student(int n){
number=n;
}
void speak(){
System.out.println("Student类的名是Tom,我的学号:"+number);
}
}
package Tom;
public class Example{
public static void main(String args[]){
Student stu=new Student(10201);
stu.speak();
System.out.println("主类的包名也是Tom");
}
}
public class Student{
int number;
Student(int n){
number=n;
}
void speak(){
System.out.println("Student类的名是Tom,我的学号:"+number);
}
}
package Tom;
public class Example{
public static void main(String args[]){
Student stu=new Student(10201);
stu.speak();
System.out.println("主类的包名也是Tom");
}
}
符号: 类 Student
位置: 类 Tom.Example4_11
Student stu=new Student(10201);
^
Example4_11.java:4: 找不到符号
符号: 类 Student
位置: 类 Tom.Example4_11
Student stu=new Student(10201);
^
2 错误
这是编译过程中报的错误
你用神马IDE啊?
2 将2个java文件复制进去
3 在Tom文件夹上一级,运行 javac -cp . Tom/*.java