DEV Community

nipun sanjula samarakoon
nipun sanjula samarakoon

Posted on

1

Create an Object in java

In Java, an object is created from a class.
To create an object of Main, specify the class name, followed by the object name, and use the keyword new:

public class Main {
int x = 5;

public static void main(String[] args) {
Main obj= new Main();
System.out.println(obj.x);
}
}

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay