Class Object in java

Create a class in java

class Person{
int age=40;
}

Create an object of class

class Person{
int age=40;

public static void main(String ar[]){
Person p=new Person();
System.out.print(p.age);
}

}
© 2016 - 2022, All Rights are Reserved.