This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring 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
Pie
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