I have this folder structure
Day12
| Account.java
| AccountMain.java
Account.java Contains
package Day12;
public class Account {
int id;
String name;
double balance;
public int getId() {
return id;
}
public String getName() {
return name;
}
public double getBalance() {
return balance;
}
public void setId(int id){
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setBalance(double balance) {
this.balance = balance;
}
}
And my AccountMain.java
package Day12;
public class AccountMain {
public static void main(String[] args) {
Account acc1 = new Account();
acc1.setId(1);
acc1.setName("John");
acc1.setBalance(1000.0);
System.out.println("Account ID: " + acc1.getId());
System.out.println("Account Name: " + acc1.getName());
System.out.println("Account Balance: " + acc1.getBalance());
}
}
Everytime I run the javac AccountMain.java I get this error.
AccountMain.java:5: error: cannot find symbol
Account acc1 = new Account();
^ symbol: class Account location: class AccountMain AccountMain.java:5: error: cannot find symbol
Account acc1 = new Account();
^ symbol: class Account location: class AccountMain
2 errors
I get confused to as I dont know ehy it says It cannot Find symbol even tho I have them in the same Package and my aitocomplete was able to detect the Account Class.
You can try the following steps
try a clean build
Check for the order of compilation or you can manually compile in the order
javac Day12/Account.java
javac Day12/AccountMain.java