symbol not found error when trying to call a user defined class using objects in another class

huangapple 未分类评论51阅读模式
标题翻译

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;

huangapple
  • 本文由 发表于 2020年5月30日 13:49:43
  • 转载请务必保留本文链接:https://java.coder-hub.com/62098391.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定