What is the difference between data types and literals in Java?
Data Type: Are nothing but a reserved memory location to store values. meaning when you create a variable you reserve some space in memory.
Literal: Is the source code representation of a fixed value, a Given or Constant value. Ex: boolean result = true
, String s1 = "Hello World"
.
boolean - is data type, result - is variable, true - is literal
String - is Object data type, s1 - is variable, "Hello World" - is literal