I am new in java, now im getting in to oop section, then i met with this constructor. ,
its been two weeks for me to getting understand how this java constructor works
And why its written in such manner
And what is exactly constructor do step by step when we call them
Also what is the anaogy of a constructor in real life
Here an example copy from web, you might tell me the work flow of a constructor in java
//Let us see another example of default constructor
//which displays the default values
class Student3{
int id;
String name;
//method to display the value of id and name
void display(){System.out.println(id+" "+name);}
public static void main(String args[]){
//creating objects
Student3 s1=new Student3();
Student3 s2=new Student3();
//displaying values of the object
s1.display();
s2.display();
}
}