Using Object in Java

Java stands out as a renowned object-oriented programming (OOP) language underpinned by the fundamental idea of objects. At its core, these objects are essentially real-world representations or instantiations of classes. Think of a class as an architectural blueprint. It outlines the potential properties (attributes) and functions (behaviors) an object can manifest. When we talk about creating an object from a class, we're referring to the procedure known as "instantiation". These objects in Java play a pivotal role; they are not just mere data holders. They encapsulate application-specific data, providing structured storage. Additionally, they come equipped with methods – predefined actions or functions – that enable developers to interact with and modify the stored data. In essence, objects in Java streamline the coding process, making data management both efficient and intuitive. In this Java Object Example, we created an object and called it in the main function. Click Execute to run the Java Object Example online and see the result.
Using Object in Java Execute
public class ObjectExample {
    public static void main(String[] args) {
		class Person {
    		String name;
    		int age;
      		public Person(String name, int age) {
 = name;
        		this.age = age;

    	public void introduce() {
        	System.out.println("Hi, I'm " + name + " and I'm " + age + " years old.");

        Person person1 = new Person("Alice", 30);      
Updated: Viewed: 36 times