Hi Satish,I think i can understand ur confusion. U have got them in the wrong context. U shouldn't be comparing primitives and literals. Primitives are the fundamental datatypes that are used to hold data in programs along with object(reference) datatypes ok? Together we can call them variables. Now a Literal "is used to assign values to variables". This variable maybe "a primitive" eg int i = 5; or "a reference" eg Integer i = new Integer("5"); type. In both cases 5 is a literal. In the first case we have a primitive i whose value is 5 and in the second case we a wrapper i whose value again is 5. A bit clearer??
There are two kinds of types in the Java programming language: primitive types (�4.2) and reference types (�4.3). There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values (�4.2) and reference values (�4.3). The primitive types are boolean, byte, short, int, long, char, float, double. The reference types are class types, interface types and array types. Variables of these types can refer to objects of the corresponding type. A literal is the source code representation of a value of a primitive type (�4.2), the String type (�4.3.3), or the null type (�4.1). Each type has literals, which are the way that constant values of that type are written. Examples of primitive literals are true, false, 'm', '\n', 10, -10, 0xff, 077, 10L, 1.23E4. This is a literal of reference type, "abc" and this is a literal of null type, null. (credits: JLS and The Java Programming Language) [ October 08, 2003: Message edited by: Marlene Miller ]
Joined: Mar 05, 2003
The JLS uses �primitive� as an adjective � a primitive type or a primitive data value (as defined above). Some people use �primitive� as a noun. Used as a noun, �primitive� means a value of a primitive type. So, comparing primitives and literals, a primitive is a value (of a variable or the result of an expression)(of type boolean, byte, short, char, int, long, float or double) and a literal is the source code representation of a value (of primitive type or reference type).