aspose 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

Win a copy of The Software Craftsman this week in the Agile forum!
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: 62312

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] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: Set a char to empty