• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what does this command mean

 
sriveena nori
Greenhorn
Posts: 1
  • 0
  • 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: 42966
73
  • 0
  • 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
  • 0
  • 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