Array of Objects in Java Programming

In this tutorial, you will learn about Array of Objects in java programming language.

You will learn what are array of objects, how to create and use them, what is the advantage of using them in detail with example.

Source Code for Student.java

 1 package oops;
 2 
 3 public class Student {
 4     private String name;
 5     private int age; 
 6     Student(){
 7         name = "noname";
 8         age = 1;
 9     }
10     
11     Student(String name, int age){
12         this.name = name;
13         this.age = age;
14     }
15     
16     void setNameAndAge(String name, int age){
17         this.name = name;
18         this.age = age;
19     }
20     
21     void introduce(){
22         System.out.println("hi i'm "+name+" and my age is "+age);
23     } 
24 }


Source Code for Tutorials.java

1 package oops;
2 
3 public class Tutorials {
4     public static void main(String[] args){  
5         Student anil = new Student();
6         Student shreesh = new Student("Shreesh",25);
7         Student anjali = new Student();  
8     } 
9 }

Watch this video to learn how this works