Java 如何修复';无法将字符串解析为类型';
在eclipse中编译代码时,抛出错误Java 如何修复';无法将字符串解析为类型';,java,Java,在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
"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”写了“字符串”
代码如下:
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);
}
}
确保已保存文件并使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);
}
}
以下是输出:
公羊
101请包括导致出现此错误的代码。您可能遗漏了分号或括号。返回并在字符串缺少接缝的一侧添加“例如,string a=“test\u string";将其添加到问题中,使其看起来像代码。您可以通过单击“编辑帖子”来完成此操作。按空格键4次,然后添加代码我的代码是这是我写的代码包Java;公共类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);}