You may assign '\u0000' (or 0). For this purpose, use Character.MIN_VALUE.

Character ch = Character.MIN_VALUE;
Answer from KV Prajapati on Stack Overflow
🌐
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
🌐
Coderanch
coderanch.com › t › 392740 › java › Set-char-empty
Set a char to empty (Beginning Java forum at Coderanch)
October 9, 2016 - programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums · this forum made possible by our volunteer staff, including ... ... 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".
🌐
Blogger
javahungry.blogspot.com › 2021 › 11 › empty-character-literal.html
[Solved] Error: empty character literal | Java Hungry
In this post, I will be sharing how to fix error: empty character literal in Java. When we need to declare an empty char, usually, we use ' ' (empty
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_represent_empty_char_in_java_character_class
How to represent empty char in Java Character class
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
Blogger
javahungry.blogspot.com › 2021 › 11 › null-character-java.html
null character java | Java Hungry
We will assign char variable ch with '\u0000'. '\u0000' is the lowest range of the Unicode system used by Java. public class EmptyCharacterExample2 { public static void main(String args[]) { // Assign null character to ch variable char ch = '\u0000'; String givenString = "Be in present"; // Replacing 'e' in the givenString with null character String result = givenString.replace('e',ch); // Printing the result string System.out.println("Replace givenString with null char: " + result); } } Output: Replace givenString with null char: B in pr s nt
🌐
Delft Stack
delftstack.com › home › howto › java › empty char in java
How to Represent Empty Char in Java | Delft Stack
February 2, 2024 - The empty string literal in Java is represented simply as "". It signifies a string with zero characters, and when used to represent an empty character, it provides a clear and widely accepted way of conveying the absence of character data.
🌐
Quora
quora.com › How-can-I-set-a-character-array-to-null-in-Java-Or-empty-it
How to set a character array to null in Java? Or empty it - Quora
Answer (1 of 6): [code]class EmptyCharArray{ public static void main(string[] args) { char namearray[6] = {'a', 'n', 'm', 'o', 'l'}; for(int i=0;i
Find elsewhere
🌐
Medium
medium.com › @javacharter › can-you-check-if-char-is-null-or-not-in-java-9f5adcc51f77
Can you check if char is null or not in Java ? | by Javacharter | Medium
April 12, 2023 - If you go through the code, I have put one condition if(ch!=0) ! Yes that is true! A char in Java cannot be null as it is a primitive . If you put a null check, it will give you compile time error.
🌐
Oreate AI
oreateai.com › blog › empty-character-java
Empty Character Java - Oreate AI Blog
December 3, 2025 - An empty character, or an empty string for that matter, is simply a string that has no length; think of it as a blank canvas waiting for something to be painted on it. In contrast, a null character signifies that there is no reference at ...
🌐
Bug Database
bugs.java.com › bugdatabase › view_bug.do
Bug ID: JDK-8067471 Use private static final char[0] for empty Strings
In an average heap dump, 292 kB is wasted from empty Strings having their own char[] of length 0. Instead, the String class should declare a zero-length char[] and use that for empty Strings.
🌐
Quora
javaguide.quora.com › How-to-initialize-an-empty-character-in-Java
http://www.quora.com/How-do-you-initialize-an-empty-character-in-Java/answer/Rahul-Salimon
This is the default character of the char data type in Java, i.e., the NULL character. There isn’t any other empty character in Java.
Top answer
1 of 3
5

A Java String is not an array of characters (nor is it a single char, which is an integral primitive type). It is an Object type, and includes a length.

JLS-10.9. An Array of Characters is Not a String says (in part)

In the Java programming language, unlike C, an array of char is not a String, and neither a String nor an array of char is terminated by '\u0000' (the NUL character).

A String object is immutable, that is, its contents never change, while an array of char has mutable elements.

I mean in the end each character in the string will be stored as a BYTE, now how a empty string will be stored?

No, each character is 2 bytes. The Java Tutorials: Primitive Data Types says

The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

In the case of an empty String there aren't any characters; and an empty array has length 0.

2 of 3
4

String is certainly backed by a char[] (a field known as value), but that does not under any circumstance imply that a String is exactly equivalent to a char[]. They're two different objects.

Now, with that out of the way, let's reason about what we're expecting with a String of length zero. This is how we determine length:

/**
 * Returns the length of this string.
 * The length is equal to the number of <a href="Character.html#unicode">Unicode
 * code units</a> in the string.
 *
 * @return  the length of the sequence of characters represented by this
 *          object.
 */
public int length() {
    return value.length;
}

The big thing here to note is that if we're creating an empty string, the length of our backing array has to be zero. So, the way that an empty String is created is by providing an empty value array at instantiation.

🌐
DaniWeb
daniweb.com › programming › software-development › threads › 425629 › how-to-check-null-character-in-an-array
java - How to check NULL character in an array [SOLVED] | DaniWeb
June 14, 2012 - In Java, there is no C-style null terminator. A char is a 16-bit primitive and cannot be null (only reference types can), and Java strings are not null-terminated; they store their length separately. For user input, prefer a String and use str.length() to know exactly how many UTF-16 code units you have, as you discovered.
🌐
Bartkessels
bartkessels.net › kotlin › empty-char-literal
Kotlin giving an empty char literal error | Bart Kessels
May 5, 2023 - When working on day three, I came accross a weird error message when trying to return an empty character from one of my methods. The return '' statement gave me this error message Empty Character Literal. So after some Googling I came accross a Java thread on Stack Overflow, saying that in Java a character can not be empty just like other primitives (the Stackoverflow post).
🌐
SSOJet
ssojet.com › special-characters › null-0-in-java
Null (\0) in Java | Special Characters in Programming Languages
The null character, \0, serves as a useful placeholder or sentinel value within Java data structures, particularly when interacting with systems that rely on null termination. Character arrays, for instance, are often initialized with \0 to ...
🌐
Oracle
docs.oracle.com › javaee › 7 › tutorial › bean-validation002.htm
21.2 Validating Null and Empty Strings - Java Platform, Enterprise Edition: The Java EE Tutorial (Release 7)
The Java programming language distinguishes between null and empty strings. An empty string is a string instance of zero length, whereas a null string has no value at all. An empty string is represented as "". It is a character sequence of zero characters. A null string is represented by null.
🌐
Baeldung
baeldung.com › home › java › java string › checking for empty or blank strings in java
Checking for Empty or Blank Strings in Java | Baeldung
January 8, 2024 - We can check out Character.isWhitespace for examples. If we’re at least on Java 6, then the simplest way to check for an empty string is String#isEmpty: