"The type of the expression must be an array type but it resolved to..."

I have a Customer class.

I have a CustomerDataHelper class that has a method that creates a Customer[][] , populates it with 10 Customers and returns it.

publicstatic Customer[] getCustomerData(){

returnnew Customer[]{

new Customer(10 ,"Hoertz","Richard","123 Main St.","San Antonio",

"TX","78230"),

new Customer(20,"Smith","John","258 Austin Blvd","Austin",

"TX","78501"),

...

}

In main I'm calling the method in CustomerDataHelper, getCustomerData, and populating Customer[] cst.

publicstaticvoid main(String[] args){

Customer[] cst = getCustomerData();

for(int i = 0; i < cst.length; i++){

int j = 0;

if (cst[i][j]== 20 || cst[i][j] == 50 || cst[i][j]== 80

|| cst[i][j]==100)

System.out.println(cst[i]);

j++;

}

My problem is my if statement, it gives me the error message listed in my Subject line for each cst[][]. It resolves it just fine in the for statement and the stdout statement, but not the if statement.

Can someone please explain?

[1983 byte] By [d011ya] at [2007-10-2 12:27:49]
# 1

You declare cst as an array of Customers, but then you access it like

cst[i][j] as if it was a double array of somethings.

Possibly you mean something likecst[i].getId() == 20

where getId() is some method of the Customer that returns whatever

that number argument in the Customer constructor is.

pbrockway2a at 2007-7-13 9:22:37 > top of Java-index,Java Essentials,Java Programming...
# 2
Don't you all post your ******* questions, error messages, stacktraces, doubts, whatever, in the ******* subject line, or at least repeat them in the body
da.futta at 2007-7-13 9:22:37 > top of Java-index,Java Essentials,Java Programming...
# 3
A perfect solution. Thanks!
d011ya at 2007-7-13 9:22:37 > top of Java-index,Java Essentials,Java Programming...