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 Make it so: Java DB Connections & Transactions this week in the JDBC 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: 90
Why java saying int as primitive data type and String as object
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11924

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: 15046

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 8 API documentation
I agree. Here's the link:
subject: What is primitive data type?
It's not a secret anymore!