wood burning stoves 2.0*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 88
Why java saying int as primitive data type and String as object
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11257
    
  16

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: 14117
    
  16

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://aspose.com/file-tools
 
subject: What is primitive data type?