Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

length

Example

Determine the number of elements present in an array.

String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars.length);

Definition and Usage

The length property provides the size of an array.

This is an inherent property in Java and is not specific to the Java Arrays Class.

Note: The length property should not be confused with the length() method used for Strings.

Syntax

array.length