Java Array size (length) example

HQ ┬╗ Java Tutorial ┬╗ Example Source Code ┬╗ Java Array Examples ┬╗ Java Array size (length) example
Java Array size (length) example 2018-02-16T07:27:54+00:00

This tutorial focuses in how to determine the array size in java. Arrays are one of the most overused storage of information in java since the declaration is easy and a lot of API’s requires this collection as an input and also as an output. Basically it holds a list of information whether its only a strings or complicated lists of objects. Focus on this knowledge, since we would be using it thoroughly on our programming life. However, I prefer more to use ArrayList since it is more flexible and has a lot more functions that is necessary on my everyday programming. But don’t get me wrong, in order to understand the much more complicated API, we should master first all the important concepts of an array.

On this article we would be focusing on determining how large is our array is. This is very important to learn since we would be using it in our loops especially if the java codes we are maintaining are still not using the advance for loop. The size is necessary to determine the upper bound of the index we should be looping in. Moreover, the size of an array might also be necessary on your business requirements.

JAVA examples : API needed in getting the array size in java

  • length – its an attribute of an array giving the current size

Java array example source code

Sample Output: [/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close