This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what does this command mean

 
sriveena nori
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char ch=(char)-1;
why should we subtract 1from char and assing it to char
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcoem to JavaRanch.

There's no subtraction here. The number "-1" is cast to a "char" - which is a Java data type. The cast is necessary because generally an integer number can't be assigned to a char. The interesting question is which character is being assigned here; can you guess which one it is, or which character code it has?
 
Manuel Leiria
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are converting the int -1 to char


[edit]to slow...[/edit]
[ July 22, 2008: Message edited by: Manuel Leiria ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic