Java/J2EE and SOA (349 Blogs) Become a Certified Professional
AWS Global Infrastructure

Programming & Frameworks

Topics Covered
  • C Programming and Data Structures (16 Blogs)
  • Comprehensive Java Course (4 Blogs)
  • Java/J2EE and SOA (346 Blogs)
  • Spring Framework (8 Blogs)

Array Of Objects In Java: Everything You Need To Know About Array Of Objects

Last updated on Mar 01,2023 47.7K Views

When you talk of Java the first thing that comes to mind is Object Oriented Programming. Java is a programming language that deals in objects. This article will focus on Array Of Objects in Java and introduce you object arrays in detail.

This article will touch up on following topics,

So let us start with the first topic of discussion

Array Of Objects In Java

The array of objects, as defined by its name, stores an array of objects. An object represents a single record in memory, and thus for multiple records, an array of objects must be created. It must be noted, that the arrays can hold only references to the objects, and not the objects themselves. Let us see how can we declare Array of objects in Java. Make sure you have Java installed n our system.

Declaring An Array Of Objects In Java

We use the class name Object, followed by square brackets to declare an Array of Objects.

Object[] JavaObjectArray;

Another declaration can be as follows:

Object JavaObjectArray[];

Let us see what else can we do with array of objects,

Declaring An Array Objects With Initial Values

Declaration of an array of object can be done by adding initial values. Here, we create an array consisting of a string with the value “Women Empowerment”, as well as an integer with the value 5.

public class Main {
public static void main(String[] args) {
Object[] JavaObjectArray = {"Women Empowerment", new Integer(5)};
System.out.println( JavaObjectArray[0] );
System.out.println( JavaObjectArray[1] );

The code produces the following output:

Women Empowerment


Let finish this article by taking a look at an example,

Example Program For An Array Of Objects

class JavaObjectArray{
public static void main(String args[]){
Account obj[] = new Account[1] ;
obj[0] = new Account();
System.out.println("For Array Element 0");
class Account{
int a;
int b;
public void setData(int c,int d){
public void showData(){
System.out.println("Value of a ="+a);
System.out.println("Value of b ="+b);


For Array Element 0

Value of a: 1

Value of b: 2

The Object is the root class of all Classes. Array appears to be a convenient data structure for holding multiple values of the same.

Thus we have come to an end of this article on ‘Array Of Objects in Java’. If you wish to learn more, check out the Java Course Online by Edureka, a trusted online learning company. Edureka’s Java J2EE and SOA training and certification course is designed to train you for both core and advanced Java concepts along with various Java frameworks like Hibernate & Spring.

Got a question for us? Please mention it in the comments section of this blog  and we will get back to you as soon as possible or you can also join our Java Training in Padang.

Upcoming Batches For Java Course Online
Course NameDateDetails
Java Course Online

Class Starts on 3rd August,2024

3rd August

SAT&SUN (Weekend Batch)
View Details
Java Course Online

Class Starts on 28th September,2024

28th September

SAT&SUN (Weekend Batch)
View Details

Join the discussion

Browse Categories

webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

Array Of Objects In Java: Everything You Need To Know About Array Of Objects