Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is "\u0000"

 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always said that default for char is '\u0000', but what is \u000?
what is the equivalent to ASCII?
Does anyone knows?
 
Dominic Steng�rd
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Nan!
'\u0000' is the null character. I don't really know what the equivalent character for this is in ASCII, or if there even exists one.
Regards
------------------
Dominic Steng�rd
Sun Certified Java 2 Programmer
------------------
 
natarajan meghanathan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
'\u000' is invalid.
'\u0000' --
decimal equivalent is 00
Char equivalent is NUL.

------------------

***********************************************
Sun Certified Programmer for Java 2 Platform
***********************************************
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well nan
first check out the hex representaion for numbers
To convert hex to decimal following steps r used
for example to \u0041 's equvalent decimal is
(1*(pow(16,0))+(4*(pow(16,1))+(0*(pow(16,2))+(0*(pow(16,3))
which is equal to
1+64+0+0=65;
hence \u0045 is equvalent to char 'A';
so applyin same for\u0000 returns 0 which is space ascii
hope u got it right
..coolpraful@rediffmail.com

[This message has been edited by praful thakare (edited February 10, 2001).]
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
Thanks for answers and I've got more confused now.
question 1 ( from nan's Mock)
What is '\u0000' represented?
a). null character
// from Dominic
b). decimal equivalent 00(zero) or null character
// from natarajan
c). space ascii
// from praful
d). a,b,c all correct
// from poor and confused nan
e). a,b,c and all wrong, right answer is ?
// from you
Answer is ???
As I know that space, null character and decimal 0 are three different things.
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well nan it's not that tough as u r taking it
go thru following code

char trustme=65;
S.O.P(trustme)
the o/p of above code will be 'A' well this is done
because every thing stored in memory is in form of 1,0 pattern
so when u say char confuse='A';
it is first converted in to it's bit pattern
so according to acsii chart value of 'A' is 65 for 'B' 66
and so on.
now comming back to ur question
\u0000 is an unicode but & the default pattern for windows
is ISO 8990_1 (some thing like that)
so as \u0000 == 0
&0 is ascii for space and as space char identifer can hold only one char it's not possible to store null in it.
This might make u more confuse but i got myself clear with
following example

int \u0041=100
S.O.P(A);
can u guess th o/p
well...... there is no error in prg
it will print 100
why ???
cause as i told befor \u0041 is for 'A'
so defining int \u0041 is same as int A;
wann some more fundays .....?
praful
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi praful,
I still hope to know what is \u0000,
Correct me if i am wrong, your first post said "\u0000" == space'.
your second post said "\u0000"==0(zero) and 0(zero)== space != null.
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey nan
see there r many was to represent the char's in java
the following r the codes giving same o/p

1)
char c=' ';
System.out.print("Befor space");//note it's print not println
for(int i=0;i<=3;++i)
{
System.out.print(c);
}
System.out.print("After space")
2)
char c=0;
System.out.print("Befor space");//note it's print not println
for(int i=0;i<=3;++i)
{
System.out.print(c);
}
System.out.print("After space")
3)
char c='\u0000';
System.out.print("Befor space");//note it's print not println
for(int i=0;i<=3;++i)
{
System.out.print(c);
}
System.out.print("After space")
so now u can represent char as
1) ' '
2) 0 (i.e decimal represent)
3)\u0000(i.e unicode representation allowed only in java
uni code is use basically when u wann represent some thing other than ascii supported by java ex japnes french & s on.
hope u get it
..praful
 
shashank hiwarkar1
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Nan,
Thanx praful,
\u0000 == space
and ascii of space is 0
 
Abhishek Anne
Greenhorn
Posts: 4
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My intention is not to confuse anyone.
My answer for this question ie '\u0000'=null character

As per my knowledge Unicode are universally unique and thus it has same meaning in java.
Now as per www.unicode.org '\u0000' stands for null.

Check out this . Search for '\u0000'
http://www.unicode.org/charts/

or
See result pfd
http://www.unicode.org/charts/PDF/U0000.pdf

Thank You
Abhishek Anne
 
Robin Kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dominic Steng�rd wrote:Hello Nan!
'\u0000' is the null character. I don't really know what the equivalent character for this is in ASCII, or if there even exists one.
Regards
------------------
Dominic Steng�rd
Sun Certified Java 2 Programmer
------------------


'\u0000' is equivalent to decimal value 0
'\u0020' is equivalent to decimal value 32

ASCII value of space is 32 also so if you use any of the above , both will result in a space character.
Hope that helps...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic