In this example we will show you how to create multiple objects of a class in Java.
Source Code
package com.beginner.examples;
public class MultipleObjects {
int i = 1;
public static void main(String[] args) {
// create multiple objects of a class
MultipleObjects a = new MultipleObjects();
MultipleObjects b = new MultipleObjects();
System.out.println(a.i);
System.out.println(b.i);
}
}
Output:
1
1