aspose file tools*
The moose likes Beginning Java and the fly likes a quick question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a quick question" Watch "a quick question" New topic
Author

a quick question

Howard Kung
Greenhorn

Joined: Jul 22, 2002
Posts: 24
Hi folks,
My computer is down, so I can't compile any java code.
Here is my question:
what will be the output of this--
char s = 3;
System.out.println(s);
Thanks


Howard Kung<br />SCJP 1.2<br />SCWCD<br />IBM Certified Specialist: WebSphere 4.0
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
It prints out: "LOVE"
Howard Kung
Greenhorn

Joined: Jul 22, 2002
Posts: 24
funny guy
Anu Kha
Greenhorn

Joined: Aug 08, 2002
Posts: 3
Ya it displays the ascii for 3
this info is just for others who might be confused why this happens.
Well if u say
char s =3 and then print s u will print the ascii char which is represented by 3
if u say char s = '3' then u get 3 as output.
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
Which happens to be the sign of a heart...so they guy really wasn't being that funny.


SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
As an added note.
I wrote the following class

I had to skip over 9 and 100. I'm running winxp and at 9 and 100 the computer would beep then stop executing the loop. Does anyone know why?
[ August 08, 2002: Message edited by: Ibrahim Hashimi ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Let's take a look at http://www.asciitable.com to see what those characters are and why issues might arise when displaying them...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm running Windows XP and I could not replicate your problem. (char)9 is the horizontal tab and (char)100 is 'd'. This program displays the corresponding characters as expected:
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
char s ;

I think it's a bad idea to name a char 's'

I had to skip over 9 and 100. I'm running winxp and at 9 and 100 the computer would beep then stop executing the loop. Does anyone know why?
Like Dirk, I had no problems with 9 and/or 100


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a quick question