How to Create an Object of a Class in Java


In this example we will show How to create a class and an object of a class in Java.

Source Code

package com.beginner.examples;

public class CreateClass { // class
  int i = 12;

  public static void main(String[] args) {
    CreateClass c = new CreateClass(); // object
    System.out.println(c.i);
  }
}

Output:

12

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments