aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why commented line is compiled? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why commented line is compiled?" Watch "why commented line is compiled?" New topic
Author

why commented line is compiled?

Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57
//char a = '\u000A';
even if i comment this line, i get compile time error. can anyone explain me why?
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

can you please post your snippet of code so that we can have a better look at your program ?
Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57
package Samples;
public class Chars
{
public static void main(String[] a)
{
String s = new String();
s = "hello";
s += "@@#";
System.out.println(s);
//char c = '\u000a';
System.out.println(c);
}
}

Output:
popo$ cd Assignments/
popo$ javac -d ./ Char1.java
Char1.java:10: unclosed character literal
//char c = '\u000a';
^
1 error
popo$
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

please refer this link http://www.coderanch.com/t/264507/java-programmer-SCJP/certification/why-char-not-compiling
Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57

Thank you so much. Can you tell me how can i find the inappropriate unicode values for the char data type?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

refer this http://unicodinator.com/#004D
Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57
I tried to add the following lines in the program. I get compile time error "illegal uniciode escape"

1. char c = '\u660';
2. char c = '\u066';

should the unicode value always be of 4 digit (hex a decimal alphabets) value?
Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57
Ilakya Mukunth wrote:I tried to add the following lines in the program. I get compile time error "illegal uniciode escape"

1. char c = '\u660';
2. char c = '\u066';

should the unicode value always be of 4 digit (hex a decimal alphabets) value?


but at the same time, the following works fine
3. char c = '\61';
4. char e = '\061';
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

\u660 is no code point in unicode code pages. there is an arabic character with code point \u0660. please check the site i linked above. the point is that you must follow exactly whatever code points the unicode guys alloted to various languages , characters all over the world.
Ilakya Mukunth
Ranch Hand

Joined: Mar 13, 2012
Posts: 57
gurpeet singh wrote:\u660 is no code point in unicode code pages. there is an arabic character with code point \u0660. please check the site i linked above. the point is that you must follow exactly whatever code points the unicode guys alloted to various languages , characters all over the world.

Thanks for the reply, what abt line 3 and 4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why commented line is compiled?