[PJUG Javamail] Another puzzel, stumpled across this one while I was coding
Brian Mason
brian at gabey.com
Sat Oct 7 17:40:45 EDT 2006
WARNING,
This is for fun. If you dont understand the statement, "This is for
fun", then please skip the email.
What is the output from each of the two functions below????
a) 134
b) 234
Are they same, are they different??
Have fun.
static public void stuff1(){
ArrayList<Integer> stuff=new ArrayList<Integer>();
int firstOne=1;
for (int i = firstOne; i < 5; i++) {
stuff.add(i);
}
stuff.remove(firstOne);
for (Integer elem : stuff) {
System.out.print(elem);
}
System.out.println("");
}
static public void stuff2(){
ArrayList<Long> stuff=new ArrayList<Long>();
long firstOne=1;
for (long i = firstOne; i < 5; i++) {
stuff.add(i);
}
stuff.remove(firstOne);
for (long elem : stuff) {
System.out.print(elem);
}
System.out.println("");
}
More information about the Javamail
mailing list