• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why commented line is compiled?

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//char a = '\u000A';
even if i comment this line, i get compile time error. can anyone explain me why?
 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please refer this link https://coderanch.com/t/264507/java-programmer-SCJP/certification/why-char-not-compiling
 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

gurpeet singh wrote:please refer this link https://coderanch.com/t/264507/java-programmer-SCJP/certification/why-char-not-compiling


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
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
refer this http://unicodinator.com/#004D
 
Ilakya Mukunth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic