What is the difference between character literals and string literals in Java?

Character literals represents alphabets (both cases), numbers (0 to 9), special characters (@, ?, & etc.) and escape sequences like
, \b etc.

Whereas, the String literal represents objects of String class.


Live Demo

public class LiteralsExample {
   public static void main(String args[]){
      char ch = 'H';
      String str = "Hello";
      System.out.println("Value of character: "+ch);
      System.out.println("Value of string: "+str);


Value of character: H
Value of string: Hello