i created 2 files… namely Shirt.java and ShirtTest.java
The code for the Shirt.java class is as follows–
public class Shirt{
public int ShirtID=0;
public String description="-description required-";
public char colorCode='U';
public double price=0.0;
public int quantityInStock=0;
public void displayShirtInformation(){
System.out.println("ShirtId:"+ShirtID);
System.out.println("ShirtDescription"+description);
System.out.println("Color Code:"+colorCode);
System.out.println("Shirt Price"+price);
System.out.println("Quantity In Stock"+quantityInStock);
}
}
The code for the ShirtTest.java is as follows–
public class ShirtTest {
public static void main (String args[]) {
Shirt myShirt = new Shirt();
myShirt.displayShirtInformation();
}
}
While i compiled the Shirt.java file.. it compiled with no errors and created a Shirt.class
file.. but when i tried to compile the ShirtTest file.. it gave an error..
Which is as follows..
> C:\java>javac ShirtTest.java
ShirtTest.java:6: cannot find symbol
symbol : class Shirt
location: class ShirtTest
Shirt myShirt = new Shirt();
^
ShirtTest.java:6: cannot find symbol
symbol : class Shirt
location: class ShirtTest
Shirt myShirt = new Shirt();
^
2 errors
What is the problem here?
p.s-both Shirt.java as well as ShirtTest.java are in the same folder
First:
javac Shirt.javaThen:
javac ShirtTest.javaAfter that you can run
ShirtTestlike that:java ShirtTest