wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Set a char to empty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Set a char to empty" Watch "Set a char to empty" New topic
Author

Set a char to empty

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
char t;
How come I cannot say t = '';
WHat are my alternatives?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61661
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Set a char to empty