File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes What is primitive data type? 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 "What is primitive data type? " Watch "What is primitive data type? " New topic

What is primitive data type?

Ganesan Ramakrishnan
Ranch Hand

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

Joined: Oct 02, 2003
Posts: 10908

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.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13868

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
Consider Paul's rocket mass heater.
subject: What is primitive data type?
Similar Threads
serizalize primitive data type
Head first strategy pattern question
Primitive data types - example for usage, please?
convert string to primitive integer
is Date a datatype ????