当我在eclipse中编译代码时,抛出错误
"Exception in thread "main" java.lang.Error: Unresolved compilation problems:
String cannot be resolved to a type
String cannot be resolved to a type
System cannot be resolved
String cannot be resolved to a type
System cannot be resolved "
但是我用大写的“ S”写了“ String”
下面是代码:
public class student {
int id;
String name;
}
class TestStudent1 {
public static void main(String[] args) {
student s = new student();
s.name = "ram";
s.id = 101;
System.out.println(s.name);
System.out.println(s.id);
}
}
答案 0 :(得分:0)
确保已保存文件并公开TestStudent1类,并将文件名更改为TestStudent1.java,如下所示,
class student {
int id;
String name;
}
public class TestStudent1 {
public static void main(String[] args) {
student s = new student();
s.name = "ram";
s.id = 101;
System.out.println(s.name);
System.out.println(s.id);
}
}
这是输出:
ram 101