aspose file tools*
The moose likes Beginning Java and the fly likes primitive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "primitive" Watch "primitive" New topic
Author

primitive

sumaraghavi ragha
Ranch Hand

Joined: Nov 17, 2006
Posts: 118
what is the differencew between a primitive and a literal?
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi sumaraghavi,

"primitives" in Java are usually the built-in primitive data types like short, int, long etc.

The term "literal" normally denotes only string literals like "hello".

Marco
Ronald Schild
Ranch Hand

Joined: Jun 09, 2008
Posts: 117
Primitives are the non-object types:

boolean
byte
char
short
int
long
float
double

Literals are hard values, like:

1
'b'
252.234f
15124321L
0x25A
"Hello world!"
false
-18


There are literals for all primitives, do you know which?


Java hobbyist.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by sumaraghavi ragha:
what is the difference between a primitive and a literal?


One can't really say what "the difference" is, because they are not closely-enough related concepts. It's like asking what's the difference between a bus and a dog.

The word "primitive" applies to the subset of Java data types that don't involve objects. This is a concept specific to the Java language.

The word "literal" means a piece of data, such as a number or a text string, that is fixed and hard-coded into your program source code. The word "literal" has about the same meaning in most programming languages.
[ June 11, 2008: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: primitive
 
Similar Threads
Nontransient primitive type
primitive type
Integer.MIN_VALUE
Is it possible to construct the same object twice?
Please brief on JavaScript architecture