Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Character literals
Character literals [message #896065] Tue, 17 July 2012 07:06 Go to next message
Jonathan Camilleri is currently offline Jonathan CamilleriFriend
Messages: 91
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 12:04 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
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
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How can I run an Eclipse Command at workspace load
Next Topic:guidance for app development
Goto Forum:
  


Current Time: Thu Apr 18 21:27:56 GMT 2024

Powered by FUDForum. Page generated in 0.02951 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top