Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects Delivering the MVP Review Arrays

Patrick Neugebauer
Patrick Neugebauer
8,799 Points

Where is the documentation for Java array objects (not the class)?

I looked up Java Array documentation and was directed here: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Array.html

This page shows no instance methods, and no fields... Where is the documentation that will show me what fields and methods an instance of the Array class has?

For example in JavaScript, MDN documentation for Array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

The docs show prototype (instance accessible) methods, static methods, and properties.

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

The Docs: https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html

An array is, in most ways, a primitive in Java much like int or char so in won't have instance fields or methods. The closest you get are the static helper methods in the Array and Arrays classes.

Patrick Neugebauer
Patrick Neugebauer
8,799 Points

Thanks!

Java does not have docs for primitives other than the specs? MDN has documentation for JavaScript primitive types: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures . It seemed pretty hard for me to verify which methods exist or don't exist on an array in Java (compared to JS or Ruby), am I doing something wrong?