Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Character literals
Character literals [message #896065] Tue, 17 July 2012 03:06 Go to next message
Jonathan Camilleri is currently offline Jonathan Camilleri
Messages: 50
Registered: July 2009
Member
Why is the following invalid?


package source;

public class CharacterPlay {

public static void main(String[] args) {
char a = 'a'

char c = 'u\16848'; //invalid character constant
System.out.println(c);

}

}


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jon>java -version
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b06)
Java HotSpot(TM) Client VM (build 23.0-b09, mixed mode, sharing)

References
Banum Unicode Chart at http://www.unicode.org/charts/PDF/U16800.pdf.
SCJP 1.6 Exam Prep written by K. Bates and Sierra. P.189



Re: Character literals [message #896144 is a reply to message #896065] Tue, 17 July 2012 08:04 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25949
Registered: July 2009
Senior Member
It helps if your example doesn't have typos... I assume you meant to
use '\uXXXX' where XXXX is the hexadecimal character value. You have
only decimal digits and too many of them.


On 17/07/2012 9:06 AM, Jonathan Camilleri wrote:
> Why is the following invalid?
>
>
> package source;
>
> public class CharacterPlay {
>
> public static void main(String[] args) {
> char a = 'a'
>
> char c = 'u\16848'; //invalid character constant
> System.out.println(c);
>
> }
>
> }
>
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\Documents and Settings\Jon>java -version
> java version "1.7.0_04-ea"
> Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b06)
> Java HotSpot(TM) Client VM (build 23.0-b09, mixed mode, sharing)
>
> References
> Banum Unicode Chart at http://www.unicode.org/charts/PDF/U16800.pdf.
> SCJP 1.6 Exam Prep written by K. Bates and Sierra. P.189
>
>
>
>
Previous Topic:How can I run an Eclipse Command at workspace load
Next Topic:guidance for app development
Goto Forum:
  


Current Time: Fri Aug 01 07:57:22 EDT 2014

Powered by FUDForum. Page generated in 0.10983 seconds