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 how to initialize char?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to initialize char??" Watch "how to initialize char??" New topic

how to initialize char??

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
how to initialize it?

like string is null int is 0

how about char?
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Have a look at The Java Tutorial: Primitive Data Types.

[How To Ask Questions On JavaRanch]
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
char '\u0000' its given there!!!

how about simple programs ??
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
'\u0000' is a valid char. Its bit value is 0000_0000_0000_0000, and it is called the null character. You can find it on this Unicode chart.

You initialise a char exactly the same way you initialise anything else; put it to the left of an assignment operator (=) and put a char literal or an expression which is convertible to a char on the right of that, then a ; sign.
I agree. Here's the link:
subject: how to initialize char??
It's not a secret anymore!