• 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

Unicode Character ??

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
here's a program which refuses to compile. I don't know what is the problem. Could anyone help me?
The code
---------
public class Unicode
{
public static void main(String a[])
{
char c1 = '\u000a'; // 1.
char c2 = '\u000b'; // 2.
System.out.println("c1 = " + c1 );
System.out.println("c2 = " + c2);
}
}
---------
The compiler gives error :- invalid character constant and ';' expected at line 1.
Thanx in advance.
-vadiraj
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it is clearly given in JLS that u can't assign LF r any special escape sequences like this.
'\u000a' is nothing but Line feed. Even u make that statement as comment also it will lead 2 an compilation error, u just check it. I have slightly altered ur program u just check it out, i remember that i seen similar question in some mock exam.
 
vadiraj vd
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
code:
--------------
public class Unicode{
public static void main(String a[]) { //char c1 = '\u000a'; // 1.
}
}
-------------------------
you are right, it gave error even if I make the line 1 as comment.
Thanks Jaganathan.
Regards,
--------
vadiraj

[This message has been edited by vadiraj vd (edited December 20, 2000).]
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic