• 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
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Character literals

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
// unicode value for character a is \u0061.

public class Test
{
public static void main(String args[])
{
System.out.println((char)('\u0061') + " ");

System.out.println((int )('\u0061') + " ");

System.out.println((char)('a') + " ");

System.out.println((int)('a'));
}
}

Answer for the above is a,97,a,97....why is it 97 when converted to int? mat be this is a basic question but i want to make clear..
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is the ASCII value of 'a'.

Also 61 base 16 = 97 base 10.
[ August 15, 2006: Message edited by: Keith Lynn ]
 
prarthana reddy
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are unicode literals represented in hexadecimal notation?
public class Test
{

public static void main(String args[])
{
System.out.println('\u033');
}

}
Why is the above code giving error ? What is the range of unicode literals ?
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by prarthana reddy:
Are unicode literals represented in hexadecimal notation?
public class Test
{

public static void main(String args[])
{
System.out.println('\u033');
}

}
Why is the above code giving error ? What is the range of unicode literals ?



The problem here is that a char literal is 16 bits, but 033 is only 12 bits.
reply
    Bookmark Topic Watch Topic
  • New Topic