Java Literals

A Java literal is a source code representation of a fixed value.

It can be assigned to any primitive type variable.


byte a = 54;
char a = ‘C’;
String a = “TutorialsDuniya”;

Java supports some special escape sequences:

Notation    Character represented
  \n	       Newline
  \r	       Carriage return
  \f	       Form feed
  \b	       Backspace
  \s	       Space
  \t	       Tab
  \"	       Double quote
  \'	       Single quote
  \\	       backslash