Forums Register Login

code output

+Pie Number of slices to send: Send
void f2(List aList) {
aList.add(new Integer(42));
}
List bList = new ArrayList();
bList.add(new Integer(41));
f2(bList);
for(int n=0; n < bList.length; n++)
{
System.out.println(bList.get(n));
}

What values will this code snippets print? Why
+Pie Number of slices to send: Send
Welcome to JavaRanch. Please UseCodeTags when you post source code.

Did you try compiling and running the code yourself? What was the output? Can you explain the output yourself? If not, then what did you expect and how is that different from what the code actually does?
Willie Smits can speak 40 languages. This tiny ad can speak only one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 558 times.
Similar Threads
K&B generics doubt
pollFirstXxx() question
Generics
Question? int[] Vs Integer[]
clarification regarding RequestDispatcher usage
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:54:42.