Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-09-2004, 08:56 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2004
Posts: 2
Default I got a JAVA Problem


Hello Everybody

Why following Commented Statement JAVAC cannot compile ??

public class Unicode
{
public static void main(String[] args)
{
//char a = '\u007';
/*char b = '\u007'*/;
}
}

It is understandable that Unicode escape should follow 4 digits after it
But why such a rule in commented statement ?
What is the reason behind this
ajayNCSTian is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 10-09-2004, 05:08 PM   #2 (permalink)
Alpha Geek
 
sujithtom's Avatar
 
Join Date: Aug 2004
Location: Not anywhere near you
Posts: 512
Default

I am no Java programmer but I don't think you can use the name Unicode as it is a reserved word. Specify you error message
sujithtom is offline  
Old 10-09-2004, 07:04 PM   #3 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2004
Posts: 2
Default

Oops My mistake ...
The Error message is :
"Illegal Unicode character." at line <so and so>

The class name is not taken by intension. I mean to say whatever you
take class name .. Error remains the Same.

Now how about it?
ajayNCSTian is offline  
Old 10-09-2004, 07:16 PM   #4 (permalink)
FooBar Guy
 
GNUrag's Avatar
 
Join Date: Jun 2004
Location: GNUmbai
Posts: 1,245
Default Re: I got a JAVA Problem

Quote:
Originally Posted by ajayNCSTian
//char a = '\u007';
/*char b = '\u007'*/;
The javac compiler makes several passes on the source code before it even checks keywords and classes... In this case, '\u007' is not a valid unicode character...

Since u're doing a program in Unicodes, you should know that unicode escape sequences are composed of a leading \u and four HEX characters...

Even when the code is commented, it will give error since, all the code is first parsed and all the unicode/hex/octal escape sequences are checked before actually compiling it...
__________________
- --
http://web.gnuer.org
GNUrag is offline  
Old 11-09-2004, 12:39 AM   #5 (permalink)
In The Zone
 
#/bin/sh's Avatar
 
Join Date: Apr 2004
Location: 42.65 N 73.76 W
Posts: 213
Default

Unicode characters are valid characters even in for your source code. Thus, the compiler sees the \u and expects a valid unicode.

Insert the following line and see that the compiler flags the last '; as an invalid constant character.

// char c = '\u000A';

\u000A is a linefeed and thus the '; begins a new source line which is a compile error.

\u followed by 4 hexadecimal characters!
Now, // String a ="sasasas\uasasasas";
__________________
\"99 little bugs in the code, 99 bugs in the code, fix one bug, compile it again, 148 little bugs in the code. 148 little bugs in the code....\"
#/bin/sh is offline  
Old 11-09-2004, 12:59 AM   #6 (permalink)
In The Zone
 
#/bin/sh's Avatar
 
Join Date: Apr 2004
Location: 42.65 N 73.76 W
Posts: 213
Default

The problem is just with \u in comments

even the strings like
// String a ="sasasas\uasasasas";
will not work
__________________
\"99 little bugs in the code, 99 bugs in the code, fix one bug, compile it again, 148 little bugs in the code. 148 little bugs in the code....\"
#/bin/sh is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by trublu
- by topgear

Advertisement




All times are GMT +5.5. The time now is 09:00 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2