Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Arrays of Objects

Posted By: Abaigael Cohen     Category: Java     Views: 4036

This article explains about how to create arrays of objects in java with different examples.

It is possible to create arrays of objects. These may have one or multiple dimensions. To create follow below steps.

1) Declare an array 
2) Allocate memory for the array elements

Syntax to create Arrays of Objects

clsName varName[ ] = new clsName[size];

clsName is a name of wrapper class for which you want to create array.
varName is a variable name given to an array.
Provide integer value in place of size to define size of number of elements in an array.

Example of Arrays of Objects

Example 1 : Program to create and display arrays of an object value

class StringArray
    public static void main(String args[])
String strArr[] = new String[2];

strArr[0] = "This is ";
strArr[1] = "an example to ";
strArr[2] = "create an array of objects.";


// Or you can use for loop to print array values

for (int i = 0; i < strArr.length; i = i + 1) 


This is an example to create an array of objects.
This is an example to create an array of objects.


Didn't find what you were looking for? Find more on Arrays of Objects Or get search suggestion and latest updates.

Abaigael Cohen
Abaigael Cohen author of Arrays of Objects is from Jerusalem, Israel.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!