Yet another Java Puzzle
No words here, just the code :)
class String
{
public static void main(String args[])
{
String String = new String();
}
}
Java, J2EE, JBoss, MySQL, Oracle, Bea WebLogic and friends
No words here, just the code :)
class String
{
public static void main(String args[])
{
String String = new String();
}
}
at
2:17 AM
5 comments:
I think there is a typo:
String String
should be
String string
Dimitri, it's the part of story :) Try to compile the code.
We can do similar thing like : Vector Vector = new Vector
because rules for declaring java identifiers (methods, variables, class names etc) permit it. See Java Specification.
Nav, yes, I know. As for me, it looks interesting...
Ah, tricky. Compiles fine, but fails to run, because its main method takes an array of that String class itself, not java.lang.String... I totally missed that. I was thinking it would fail to compile, and now I'm not sure why I thought that...
Post a Comment