public class student
{
int id;
String name;
String rollno;
student(int i, String n, String r)
{
id=i;
name= n;
rollno= r.toString();
}
student(student s1)
{
id=s1.id;
name=s1.name;
rollno=s1.rollno;
}
void display()
{
System.out.println(id+" "+name+" "+rollno);
}
public static void main(String[] args)
{
student obj1=new student(2197,"Himanshu","21bcs5642");
student obj2=new student(obj1);
obj1.display();
obj2.display();
}
}
No comments:
Post a Comment