This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes What is primitive data type? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "What is primitive data type? " Watch "What is primitive data type? " New topic
Author

What is primitive data type?

Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 85
Why java saying int as primitive data type and String as object
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

because that's what they are.

Java, in a sort of carryover from C/C++, has about a half-dozen primitive types. int, char, double, etc. they are not true 'objects' in that they don't have methods, member variables, or anything one would normally associate with objects.

a String IS an object. in fact, everything in java that is not a primitive is an object.


Never ascribe to malice that which can be adequately explained by stupidity.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12953
    
    3

To be precise, there are eight primitive data types in Java: byte, short, int, long, char, boolean, float, double.

For more information, see: The Java Tutorials - Primitive Data Types.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: What is primitive data type?
 
Similar Threads
Primitive data types - example for usage, please?
Head first strategy pattern question
is Date a datatype ????
convert string to primitive integer
serizalize primitive data type