What is the difference between data types and literals in Java?
From Java Data types tutorial
Data types :
Primitive types are special data types built into the language; they are not objects created from a class
Literal :
A Literal is the source code representation of a fixed value; literals are represented directly in your code without requiring computation
boolean result = true;
boolean - is data type
true - is literal
Data Type : it defines the memory assignment for different "types" available in java.
source http://javawebtutorial.blogspot.in/2013/10/data-types-in-java-as-you-all-know-that.html
Literals : Literals in java define the actual value we can using for variables, constants or to perform any operation.
source : http://javawebtutorial.blogspot.in/2013/10/literals-in-java-literals-in-java.html
A literal is a fixed value that is assigned to a variable (of a specific data type) directly without using a constructor
For eg:
String var1 = "Java"; -- here "Java" is a literal
String var2 = new String("Java"); -- here "Java" is not a literal
Data types are just, well, different types of data, like Strings or floats or ArrayLists. In Java, most data types are classes. Edit although according to one of the other answers, I think maybe the term "data type" might be used more for primitives, i.e. types that are not classes.
A literal is a way of expressing a value without having to create it using a constructor. For example, if you just put 3 in your code, it means the int 3. You don't have to say new Integer(3) or anything like that.
By the way, may I recommend the official Java Tutorials.