Link

Puzzle (Hello Whirled)

/**
 * Generated by the IBM IDL-to-Java compiler, version 1.0
 * from F:\TestRoot\apps\a1\units\include\PolicyHome.idl
 * Wednesday, June 17, 1998 6:44:40 o'clock AM GMT+00:00
 */
package demo;

public class App {
  public static void main( final String[] args ) {
    System.out.print( "Hell" );
    System.out.println( "o world" );
  }
}

What do you think the above will print, if you get it to compile!!

This example was taken from PUZZLE 15: HELLO WHIRLED in Java™ Puzzlers: Traps, Pitfalls, and Corner Cases.

The problem is in the third line of the comment, which contains the characters \units. These characters begin with a backslash (\) followed by the letter u, which denotes the start of a Unicode escape. Unfortunately, these characters are not followed by four hexadecimal digits, so the Unicode escape is ill-formed, and the compiler is required to reject the program. Unicode escapes must be well formed, even if they appear in comments.