• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Array types clarification ....

 
Ranch Hand
Posts: 173
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We know that arrays in java are objects...
Then where we can find documentation for each array type??

Correct my question if it was wrong??

Thanks in advance...
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you create array of Object then look in Object class. If you have created array of String class then look at String class. If you have created of some interface array then look that one in docs.
 
Hareendra Reddy
Ranch Hand
Posts: 173
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pramod P Deore wrote:If you create array of Object then look in Object class. If you have created array of String class then look at String class. If you have created of some interface array then look that one in docs.



Actually my doubt is where we can find the API documentation for array types...
In K&B (page: 225) it is written that arrays have only public variable length that gives number of elements...
I just want to have a look at that ...

And in the same way what about multidimensional arrays??
 
Saloon Keeper
Posts: 14510
325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multi-dimensional arrays are no different from other arrays. They are exactly the same, except their return type is simply another array.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hareendra Reddy wrote:

Actually my doubt is where we can find the API documentation for array types...
In K&B (page: 225) it is written that arrays have only public variable length that gives number of elements...
I just want to have a look at that ...



Given below are the array members,
  • The public final field length, which contains the number of components of the array (length may be positive or zero)
  • The public method clone, which overrides the method of the same name in class Object and throws no checked exceptions
  • All the members inherited from class Object; the only method of Object that is not inherited is its clone method


  • For more details, have a look on JLS.

     
    Hareendra Reddy
    Ranch Hand
    Posts: 173
    Firefox Browser Fedora Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you Abimaran for the information ...
     
    Abimaran Kugathasan
    Ranch Hand
    Posts: 2066
    IntelliJ IDE Clojure Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Hareendra Reddy wrote:Thank you Abimaran for the information ...



    You are welcome.
     
    Ranch Hand
    Posts: 820
    IntelliJ IDE VI Editor Tomcat Server
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Hareendra Reddy wrote:

    Actually my doubt is where we can find the API documentation for array types...
    In K&B (page: 225) it is written that arrays have only public variable length that gives number of elements...
    I just want to have a look at that ...



    Java Arrays are somewhat mysterious. If you look up Array api, you get something in the java.lang.Reflect package, which, while related, is not on the exam and not required to work with arrays.

    if you do:


    you get:


    it sounds like you want to see the api for [Ljava.lang.String and there just isn't any.
    all arrays make available a field length, which is implemented as a public final int. Same for [I, [D, etc....
    You would think there would be an array parent class that these all inherit from and that there would be an API that you could read for this parent. Well, there isn't. The superclass of any of these array types is Object.
    so, we have Object
    and then inheriting from object, we have all types of arrays

    but, if object B is a subtype of object A, then an array B[] is a subtype of array A[]
     
    Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic