The reason why i could not figure this out is first of all :
1) It looked straightforward ( overconfidence stepped in )
2) I was used to the for(int counter = 0; counter< ...; counter++) way of writing for loops and indexing arrays.
Whatever said, this one was a good puzzle. And i will NOT forget this one all my life :) !
public class Main {
public static void main(String... pArgv) {
int []arr = {1,2,3,4};
for ( int i : arr )
{
arr[i] = 0;
}
for ( int i : arr )
{
System.out.print(i);
}
}
}
public static void main(String... pArgv) {
int []arr = {1,2,3,4};
for ( int i : arr )
{
arr[i] = 0;
}
for ( int i : arr )
{
System.out.print(i);
}
}
}
By the way the output is : 0030
No comments:
Post a Comment