• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is primitive data type?  RSS feed

 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why java saying int as primitive data type and String as object
 
fred rosenberger
lowercase baba
Bartender
Posts: 12443
42
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15865
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!