Programming Geek
Rated 4.7/5 based on 1446 reviews

Tricky problem in JAVA

A Tricky Problem in JAVA Regarding Comment

In JAVA program we generally use two types of comments single line comments and multiline comments. A comment is generally used for internal documentation of the source code. But there is a tricky problem containing a single line comment due to which the program does not compile at all.

 * @author VIK
public class Tricky{
    public static void main(String... v)
        //u000A this line causes problem
        System.out.println("howdy, how are you...");

When we compile the above program, the following errors are generated:


1) When we compile a java program then before compilation the java compiler processes the source code.
While processing the source code it replaces the unicode character with its value.That's why the errors were
encountered during compilation.  

2)Since \u000A is the line feed character, before compilation it is replaced with a new line character and
compile time errors occur. 3) Same behaviour can be observed using \u000D because it is a carriage return character in unicode.

No comments :

Post a Comment