标题翻译
symbol not found error when trying to call a user defined class using objects in another class
问题
code 1:
package hello;
public class hi
{
int x=30;
}
code 2:
package hello;
public class hii
{
public static void main(String args[])
{
hi ob=new hi();
int u= ob.x+33;
System.out.println(u);
}
}
编译code 2时出现的错误:
错误:找不到符号
hi ob = new hi();
^
错误:找不到符号
hi ob = new hi();
^
英文翻译
code 1:
package hello;
public class hi
{
int x=30;
}
code 2:
package hello;
public class hii
{
public static void main(String args[])
{
hi ob=new hi();
int u= ob.x+33;
System.out.println(u);
}
}
error when compiling code 2:
error:cannot find symbol
hi ob =new hi();
^
error:cannot find symbol
hi ob =new hi();
^
答案1
得分: 0
你需要导入这个类:
import hello.hi;
英文翻译
You have to import the class:
import hello.hi;
专注分享java语言的经验与见解,让所有开发者获益!
评论