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

simple doubt on char

kiran vydhyam
Greenhorn

Joined: Jul 22, 2004
Posts: 7
when I declare chars,ex: char c=1; ,is it not neccessary that I quote the value with single quotes whether the value is an integer or a letter.
char c='1';
char c=1;
what is the differce here.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
I suggest you try writing a tiny program that sets char c1='1' and char c2 = 1 and then does a Systen.out.println( "c1 = " + c1 + " c2 = " + c2 ) and let us know the results.
[ July 22, 2004: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
As a slightly tangential note, I reference http://www.asciitable.com when I'm curious for the occasional ASCII (character) value.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Ripan Karmakar
Greenhorn

Joined: Jul 28, 2004
Posts: 16
Source Code:
public class Char
{
public static void main(String args[])
{
char c1=1;
char c2='1';

System.out.println("c1=" + c1 + " and " + "c2=" + c2 ) ;
}
}


o/p: c1=☺ and c2=1

that means: 1st one gives the ASCII Value of 1
2nd one gives the value as within ' '


"Strenght is Life and Weakness is Death"<br />Java/J2EE Developer<br />UshaComm Pvt. Ltd, Kolkata, INDIA
Sadanand Murthy
Ranch Hand

Joined: Nov 26, 2003
Posts: 382
Originally posted by Ripan karmakar:
Source Code:
public class Char
{
public static void main(String args[])
{
char c1=1;
char c2='1';

System.out.println("c1=" + c1 + " and " + "c2=" + c2 ) ;
}
}


o/p: c1=☺ and c2=1

that means: 1st one gives the ASCII Value of 1
2nd one gives the value as within ' '


Bummer, man. You robbed the OP of finding this out himself/herself.
[ July 29, 2004: Message edited by: Sadanand Murthy ]

Ever Existing, Ever Conscious, Ever-new Bliss
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple doubt on char