• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set a char to empty

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char t;
How come I cannot say t = '';
WHat are my alternatives?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char is a primitive type that contains a character value. Asking why it cannot be set to "empty" is like asking why an int can't be set to "empty".
The closest approximation is to set it to the null character a la:

hth,
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic