Java Reference
In-Depth Information
void main(
String[]
args){
System.out
.println(
"Hello w"+
"orld");}}
Here is how it looks after cleaning up the formatting:
public class Ugly {
public static void main(String[] args) {
System.out.println("Hello w" + "orld");
}
}
The lesson of this puzzle is: Just because you can doesn't mean you should. Alternatively, If it hurts
when you do it, don't do it! More seriously, this puzzle serves to reinforce the lessons of the
previous three: Unicode escapes are essential when you need to insert characters that can't be
represented in any other way into your program. Avoid them in all other cases. Unicode
escapes reduce program clarity and increase the potential for bugs.
For language designers, perhaps it should be illegal to use Unicode escapes to represent ASCII
characters. This would make the programs in Puzzles 14 , 15 , and 17 (this puzzle) invalid,
eliminating a great deal of confusion. This restriction would cause no great hardship to
programmers.
< Day Day Up >
 
 
Search WWH ::




Custom Search