This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple doubt on char

 
kiran vydhyam
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a slightly tangential note, I reference http://www.asciitable.com when I'm curious for the occasional ASCII (character) value.
 
Ripan Karmakar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ' '
 
Sadanand Murthy
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic