File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 60782
    
  65

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]
 
jQuery in Action, 2nd edition
 
subject: Set a char to empty
 
Similar Threads
please explain. char problem.
Help needed on following questions
Char assignment
Q how does the above code give error and the code below doesn't???
char range