0

I am using NetBeans and am trying to create an object of class Two in class One. class Two is in a file Two.java and class One is in a file One.java.

One.java

public class One 
{
    public static void main(String[] args)
    {
            Two obj = new Two();
            obj.ReceiveData("Hello");
    }
}

Two.java

public class Two 
{
    public void ReceiveData(String str)
    {
      System.out.println(str);
    }

}

Both of the files(One.java and Two.java) are within the same (default)package.

Same Package

Same Package

However, i am getting an error stating,

cannot find symbol: class Two, location class One

When both the classes are in the same file, there is no error and class Two object can be created in class One. Where am i wrong?

SatyaTNV
  • 4,137
  • 3
  • 15
  • 31

0 Answers0