• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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).]
 
It's feeding time! Give me the food you were going to give to this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic