• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why commented line is compiled?

 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//char a = '\u000A';
even if i comment this line, i get compile time error. can anyone explain me why?
 
gurpeet singh
Ranch Hand
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please post your snippet of code so that we can have a better look at your program ?
 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 924
1
Fedora Java Netbeans IDE
 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
refer this http://unicodinator.com/#004D
 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 924
1
Fedora Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
\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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic