I just started with Java package and wanted do something easy first. So i did 2 classes and I get an error why Im creating an object of the second class.
Error: Could not find or load class main
I get this error using
javac *.java
Here is my code
package person;
public class Main {
public static void main(String[] args) {
Person p1 = new Person();
p1.setFirstName("John");
p1.setAge(20);
System.out.println(p1.getAge());
}
}
And second class
package person;
public class Person {
private String firstName;
private int age;
public Person() {
}
public void setFirstName (String n)
{
firstName = n;
}
public void setAge(int a)
{
age = a;
}
public int getAge()
{
return age;
}
}
when I compile file one by one i get this error
Error: cannot find symbol
Person p1 = new Person();
And it is pointing at Person before p1 and Person after new. All files are in the same file, so i dont know whats the mistake here.