Thread: array problem
View Single Post
  #2 (permalink)  
Old 12-12-2007, 09:08 AM
spoon! spoon! is offline
Member
 
Join Date: Dec 2007
Posts: 12
spoon! is on a distinguished road
wow this code has a lot of problems

1.
Code:
while(z.get_ant-ar() != "end")
this is a typo, should probably be
Code:
while(z.get_ant_ar() != "end")
2.
that while loop will never exit, because "z.get_ant_ar()" will never return "end"; count will keep incrementing; but when "count" gets to 3,
Code:
ar[count]
will be out of bounds

3.
Code:
ar[count] = z.get_ant_ar();
Code:
System.out.println(ar[count]);
it seems from these lines that "ar" should be a "String[]" instead of a "ant[]"

4.
Code:
return "ant";
the ant method get_ant_ar() always returns the literal string "ant". it sets the "ant" instance variable, but never uses it; perhaps you wanted to instead
Code:
return ant;
Reply With Quote