This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design forum!
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: 63232
    
  69

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set a char to empty
 
It's not a secret anymore!