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

Are arrays objects in Java?

 
Lokanadham Nalla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I read in some book as "Arrays are objects in Java" and also "All arrays of reference type are subtypes of the array type Object[], but arrays of primitive data types are not. Note that the array type Object[] is also a subtype of Object type".

How is the first statement "Arrays are onjects in Java" true for primitive type arrays? Are primitive type arrays not objects?

Thanks,
Loka
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The arrays are objects in JAVA including primitive type arrays, See JLS
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All arrays (the thing that contains the elements) are Objects. The elements of an array (what an array contains), may be either an Object or a primitive.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic