I am learning Java. I am using NetBeans. I created a new project named TestCircle using the default package name provided by NetBeans, which is the same as the file name but all in lower case. The file is TestCircle.java :
Then I right-clicked the project name and added a new class file named Circle:
I right-click the project and do a Clean and Build. There are no errors.
But when I un-comment the line:
I get a compile error. Here is part of the compile output:
So it looks like as soon as I try to instantiate a Circle object, the TestCircle class cannot find the Circle class!
What am I doing wrong? Thanks for any help!
Code:
// TestCircle.java
package testcircle;
public class TestCircle {
public static void main(String[] args) {
//Circle myCircle = new Circle();
}
}
Code:
// Circle.java
public class Circle {
int radius;
// constructor
Circle(){
}
}
But when I un-comment the line:
Code:
//Circle myCircle = new Circle();
Code:
Compiling 2 source files to C:\Users\JohannFu\Documents\NetBeansProjects\TestCircle\build\classes
C:\Users\JohannFu\Documents\NetBeansProjects\TestCircle\src\testcircle\TestCircle.java:6: cannot find symbol
symbol : class Circle
location: class testcircle.TestCircle
Circle myCircle = new Circle();
C:\Users\JohannFu\Documents\NetBeansProjects\TestCircle\src\testcircle\TestCircle.java:6: cannot find symbol
symbol : class Circle
location: class testcircle.TestCircle
Circle myCircle = new Circle();
2 errors
What am I doing wrong? Thanks for any help!
Comment