Typically for local variables I initialize them as late as I can. It's rare that I need a "dummy" value. However, if you do, you can use any value you like - it won't make any difference, if you're sure you're going to assign a value before reading it.

If you want the char equivalent of 0, it's just Unicode 0, which can be written as

char c = '\0';

That's also the default value for an instance (or static) variable of type char.

Answer from Jon Skeet on Stack Overflow
🌐
Delft Stack
delftstack.com › home › howto › java › initialize char in java
How to Initialize Char in Java | Delft Stack
February 2, 2024 - To initialize a char in Java, we can use any char value such as an empty char, or \0, or even a char value itself. While creating a char variable, we must first understand if the declared variable is local or instance because if the variable ...
Discussions

java - How to init char array using char literals? - Stack Overflow
The following statement doesn't work in Java, but works in C: char c[] = "abcdefghijklmn"; What's wrong? Does the char array can only be initialized as following? char c[] = {'a', 'b', 'c', 'd'... More on stackoverflow.com
🌐 stackoverflow.com
Java character array initializer - Stack Overflow
When you attempt to print each ... was no functionality to add in the characters from the input String to the array. You have everything around it correctly implemented, though. This is the code that should go after you initialize the array, but before the for-loop that ... More on stackoverflow.com
🌐 stackoverflow.com
What is the initial values of char arrays?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
9
7
October 15, 2021
java - Initializing with Character vs char array - Stack Overflow
char is autoboxed to Character which I had used in char array initailizer..Why am I getting different results! More on stackoverflow.com
🌐 stackoverflow.com
People also ask

Why is char in Java fixed at 2 bytes?
Char in Java uses UTF-16 encoding, requiring 2 bytes per character to represent a vast range of characters. The 2-byte size ensures efficient use of memory. This design choice balances global character support with memory efficiency. It allows Java to handle various international languages without excessive memory overhead.
🌐
upgrad.com
upgrad.com › home › blog › software development › complete guide to char in java: declaration, size, common use cases and more
Exploring Char in Java: Size, Declaration, and Applications
When should I use a char array over a StringBuilder in Java?
Use char arrays when you need to frequently modify characters in place, such as for encryption or parsing. StringBuilder is designed for appending or altering string content efficiently and should be used when constructing larger strings. Char arrays are preferable when working with individual characters and memory optimization is key. For mutable, high-performance operations on characters, char arrays are ideal.
🌐
upgrad.com
upgrad.com › home › blog › software development › complete guide to char in java: declaration, size, common use cases and more
Exploring Char in Java: Size, Declaration, and Applications
How does UTF-16 encoding impact the use of char in Java?
Javas char data type uses UTF-16 encoding, which allows the representation of over 65,000 characters, supporting global languages. This encoding ensures Java applications can handle diverse scripts. Every character is stored using 2 bytes, ensuring compatibility with various systems. Understanding Unicode helps developers handle non-Latin characters effectively across applications.
🌐
upgrad.com
upgrad.com › home › blog › software development › complete guide to char in java: declaration, size, common use cases and more
Exploring Char in Java: Size, Declaration, and Applications
🌐
Coderanch
coderanch.com › t › 412179 › java › initialize-char
how to initialize char?? (Beginning Java forum at Coderanch)
October 9, 2016 - 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.
🌐
Javatpoint
javatpoint.com › char-keyword-in-java
Java char keyword - Javatpoint
Java char keyword - The Java char keyword is a primitive data type. It is used to declare the character-type variables and methods. It is capable of holding the unsigned 16-bit Unicode characters.
🌐
Coderanch
coderanch.com › t › 616347 › java › char-array-initialization-dynamically
char array initialization dynamically (Beginning Java forum at Coderanch)
And also ... taking guesses on what is implied from the pseudo code ... it looks like you are trying to store each car's name, which is a string, into a single character. This doesn't sound reasonable, does it? Henry · Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor) ... k... sorry.. got my mistakes.. thanks a lot!! so i think i have to initialize my array directly like char strtsnh[] = {'hyundai','bmw'};
🌐
Upgrad
upgrad.com › home › blog › software development › complete guide to char in java: declaration, size, common use cases and more
Exploring Char in Java: Size, Declaration, and Applications
June 11, 2025 - In this example, you will initialize a char in Java array with predefined values, specifically the vowels 'a', 'e', 'i', 'o', 'u'. This shows how to initialize a char in Java array and print its contents.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › java › java_characters.htm
Java - Character Class
Java Vs. C++ ... Normally, when we work with characters, we use primitive data types char.
🌐
iO Flood
ioflood.com › blog › java-char
Char Data Type in Java: How to Declare and Use
February 26, 2024 - JavaTpoint’s Java Char Tutorial offers an overview of chars in Java, including how to declare, initialize, and use them.
🌐
Quora
quora.com › How-do-I-declare-a-char-variable-in-Java-and-give-inputs
How to declare a char variable in Java and give inputs - Quora
Answer (1 of 7): Thanks for A2A :) Declaring Variable and giving Inputs in Java can be done in 2 Steps. Step-1 Declaring Variable Syntax to declare any variable in Java is : Datatype variable_name; OR Datatype variable_name = value; For example to create an char and int variable, char c; ...
🌐
Edureka
edureka.co › blog › character-array-in-java
Char Array In Java | Introduction To Character Arrays In Java | Edureka
July 5, 2024 - Declaration of a char array can be done by using square brackets: ... The square brackets can be placed at the end as well. ... A char array can be initialized by conferring to it a default size.
🌐
Homework.Study.com
homework.study.com › explanation › how-to-declare-and-initialize-char-grade-a-in-eclipse.html
How to declare and initialize char grade = 'A' in Eclipse | Homework.Study.com
Using Java, create a class called Date that includes three instance variables: month (of type int), day (of type int), and year (of type int). Provide a constructor that initializes the three instance · Consider the following code: char string1[25] = "Total Eclipse "; char string2[11] = "of the Sun"; cout string1 endl; cout string2 endl; strcat(string1,string2); cout string1 endl; 1
🌐
Reddit
reddit.com › r/javahelp › what is the initial values of char arrays?
r/javahelp on Reddit: What is the initial values of char arrays?
October 15, 2021 -

So, I'm learning about arrays using int name = new int[5] where it creates a fixed size array (in this case, it has 5 items of arrays).

As for int, it will fill it with 0 in each item as the initial values. For boolean, false. For double, 0.0. For String, null.

But then, I tried create the char array. But, when I printed it out, it shows weird values. This is what it prints out on my command line. What the hell is that?

Top answer
1 of 2
3
See this for default values of datatypes. The default value of char is the NULL character ('\u0000'), because char is numeric on the inside and will have a default value of 0, which maps in the ASCII table to that character. NULL will not be properly displayed.
2 of 2
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Huda Tutorials
hudatutorials.com › java › basics › java-arrays › java-char-array
Java char Array - char array in java - Huda Tutorials
July 16, 2021 - A char array can be initialized by conferring to it a default size. //initializing java char array char[] java_char_array = new char[10];
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java char – character data type in java with examples
Java char - Character Data Type In Java With Examples
April 1, 2025 - All these integer variables that are initialized with the numeric value belong to some character. For example, 66 belongs to B, 76 belongs to L, etc. You cannot specify any random integer and try to typecast it. In such cases, the compiler will fail to typecast and as a result, it will throw ‘?’ in the output. import java.util.Arrays; public class example { public static void main(String[] args) { int number1 = 66; char chars1 = (char)number1; int number2 = 76; char chars2 = (char)number2; int number3 = 79; char chars3 = (char)number3; int number4 = 71; char chars4 = (char)number4; System.out.println(chars1); System.out.println(chars2); System.out.println(chars3); System.out.println(chars4); } }
🌐
LinuxQuestions.org
linuxquestions.org › questions › programming-9 › empty-char-in-java-95407
empty char in java
September 22, 2003 - Hi everyone, I want to initialize an empty char in java, but I just found out that isn't as simple as I thought. I tried Code: char ch = ''; But that