---
title: "Java Array Vs. Scala Array Which is Easy"
description: "Here is the quick syntax of arrays declaring in Java and Scala. It is handy for programmers who wish to learn more."
url: https://srinimf.com/2021/07/23/scala-vs-java-the-real-difference-in-array/
date: 2021-07-23
modified: 2026-10-09
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2021/07/pexels-photo-6457514.jpeg?fit=1880%2C1253&ssl=1
categories: ["JAVA"]
tags: ["Arrays Java Vs Scala"]
type: post
lang: en
---

# Java Array Vs. Scala Array Which is Easy

An array is a fixed-size box with elements. The index of elements starts from ‘0’. The last element of an array is -1 of the length of an array.

Arrays are most common in modern languages like Java and Scala. Here is the difference in declaring an array.

## [How to declare](https://srinimf.com/2011/10/15/pli-declaring-arrays/) an Array in Java

You declare an array type in Java by appending [] to the type. For example, an array of ints is defined as int[].

```
1   int[] vampireAges = new  int[10]; // ten vampires
```

Setting and accessing the values in an array uses the same square bracket syntax, such as the following:

```
1   vampireAges[0] = 1565; // set age of first vampire
2   int age = vampireAges[0]  // get age of first vampire
```

As you can see, the first index of an array is zero. Things tend to start at zero when programming; try to remember this.

![](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/07/pexels-photo-1133957.jpeg?resize=1880%2C1255&ssl=1)

## **Java Vs. COBOL Arrays**

Here you will know the syntax to define arrays in Java and COBOL.

[more](https://srinimf.com/2015/09/28/differences-of-cobol-tables-vs-java-arrays/)

## How to Declare an Array in Scala

In Scala, you can define an Array like one of the following:

```
1   var names = new Array[String](2) // size of 2 without values
2   var names = Array("Dracula", "Edward") // size of 2 with values
```

Related Posts

- [How SCALA and Hadoop Can be Integrated](https://srinimf.com/2017/09/08/the-story-develop-scala-applications-to-access-hadoop-data/)DateSeptember 8, 2017
- [COBOL Table vs Java arrays Top Differences](https://srinimf.com/2015/09/28/differences-of-cobol-tables-vs-java-arrays/)DateSeptember 28, 2015
- [Java ‘Collections’ vs COBOL ‘Arrays’](https://srinimf.com/2015/10/05/java-collections-for-mainframe-programmers/)DateOctober 5, 2015

- ## How to Find Databricks Job Status, Owner, and Active Runs Fast October 17, 2026
- ## 30 SQL Practice Queries with Solutions — Run Them Live October 1, 2026
- ## Supercharge Your Database Skills: Try Our New Interactive SQL Plugin! September 30, 2026

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2021%2F07%2F23%2Fscala-vs-java-the-real-difference-in-array%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2021%2F07%2Fpexels-photo-6457514.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=Java%20Array%20Vs.%20Scala%20Array%20Which%20is%20Easy)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2021/07/23/scala-vs-java-the-real-difference-in-array/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2021/07/23/scala-vs-java-the-real-difference-in-array/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2021/07/23/scala-vs-java-the-real-difference-in-array/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2021/07/23/scala-vs-java-the-real-difference-in-array/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Java%20Array%20Vs.%20Scala%20Array%20Which%20is%20Easy&body=https%3A%2F%2Fsrinimf.com%2F2021%2F07%2F23%2Fscala-vs-java-the-real-difference-in-array%2F&share=email)
-

### Like this:

Like Loading…
