• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

primitive

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the differencew between a primitive and a literal?
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic