java
What is actual default value of a char in java? [duplicate]
This question already has an answer here: what's the default value of char? 13 answers class CHar { public static void main(String []l) { char j='\u0000'; System.out.println("value of char j="+j); } } When I print the value of j then it prints nothing it means null value, but java dic says the default value of char is '\u0000' with which I agree, but the default value should be print. Instead of printing the default value it prints C:\Users\Mohit-Pc\Desktop\Java Array>java CHar value of char j= That it is nothing means null. I'm still confused, whether I use instead of char default value, null then it generates an error: CHar.java:5: error: incompatible types: cannot be converted to char char j=null;
A char with value 0 is the NUL character. It is a non-printing character and does not display as anything. Traditionally, C-style strings use a NUL character to mark the end of a string. Note that the NUL character is different from the Java null. NUL is a primitive char value, while null is a reference value. The char type cannot hold a value of null, but an object type like java.lang.Character can. If you want to print the numeric value of a char, cast it to int first.
Related Links
insert method for Priority Queue using Linked Lists
RealList in RealmObject not automatically loaded
Java renameTo() failing some time, where I can see OS logs
JButton can't be resolved inside actionListener
Log4j Version 1.x: How to create different log files for different users?
How to print graph without excess lines
Getting Firebase displayName to write
Jersey client REST API generates http 403 error
Method won't save variable. Instead just printing out as 'null' [duplicate]
Create enum variables inside a singleton class in Java
Image from Desktop not displaying (Java)
Not able to click on element although click in not throwing error
JUnit AssertionFailedError: Text in the file differs in java
Select elements from joined ElementCollection
GUI calculation issue [closed]
jersey rest service with tomcat not working with welcome file configuration in web.xml