Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

datatypes in java

 
wrushasen dakhane
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know only 2 datatypes in java

1. Primitive data types
2. Reference data types

I have been told in some interview that there is 3 rd also ..

Does anybody have idea about that.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the exact wording of the question might matter. Either that, or the interviewer was having you on, to see how well you'd argue your corner.

Variables and fields in Java are either object references or not object references. The term for any that aren't object references is "primitive". There are several primitive data types: int, float etc.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Language Specification says
There are two kinds of types in the Java programming language: primitive types (�4.2) and reference types (�4.3).
That's the second edition which comes up at the top of my Google search, but I don't think Java has been changed to include any new types since then.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by wrushasen dakhane:
... I have been told in some interview that there is 3 rd also ...

My response to that would have been: "What?"
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The third edition words it a little differently but the meaning is still the same.

The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types (�4.2) are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types (�4.3) are class types, interface types, and array types. There is also a special null type. An object (�4.3.1) is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object (�4.3.2). String literals are represented by String objects (�4.3.3).

http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic