Ive got this kinda stupid exam question in which I'm told to make an array of objects IN MAIN method.
I defined the class Account with two variables - String owner and double amount.
Then I'm told to make the Account class handle change of values sum of all amounts. etc.
But I cant figure out what I'm doing wrong - I cannot get access to the array from getAmount().
public static void main(String[] args)
{
Account[] account = new Account[10];
for ( int i=0; i<account.length; i++)
{
account[i]=new Account();
}
account[0].owner = "Thomas";
account[0].amount = 24325;
System.out.println(getAmount(0)); //<- dont work, but works with account[0].amount
}
public static double getAmount(int x)
{
double s = account[x].amount; //<<------- CANNOT FIND SYMBOL
return s;
}