You want to loop through an array and stop when you come to the last element. Being a good java programmer and forgetting everything you ever knew about C/C++ you know that arrays contain information about their size. Which of the following can you use?
1)myarray.length();
2)myarray.length;
3)myarray.size
4)myarray.size();
Answer 2) myarray.length;
The String class has a length() method to return the number of characters. I have sometimes become confused between the two.
No comments:
Post a Comment