File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

Joined: Jan 10, 2002
Posts: 63858

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:


[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Set a char to empty
jQuery in Action, 3rd edition