• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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 live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic