Friday, May 22, 2009

Java Puzzles - 25

I read Twisters - The new age Java Quiz a blog with cool content. This is one of the latest puzzles and it made me think a lot! Enjoy it
package com.twisters;
public class UnIncrement{
public static void main(String[] args) {
int x = 0;
x
++;
System.out.println(
"X is : " + x);//This must print 'X is 0'
}
}

The idea is that you have to make that code print 0 changing only one char in the source!


Hint: think about bits

No comments:

Post a Comment