Skip to content

Instantly share code, notes, and snippets.

@PabloHdzVizcarra
Created April 1, 2022 19:00
Embed
What would you like to do?
copy constructor object
package jvm.pablohdz.prototypepatternapi;
/**
* implementation of the Student class with copy constructor
* */
public class Student {
int rollNo;
String name;
public Student(int rollNo, String name) {
this.rollNo = rollNo;
this.name = name;
}
public Student(Student student) {
this.rollNo = student.rollNo;
this.name = student.name;
}
public void displayDetails() {
System.out.println("Roll No: " + rollNo);
System.out.println("Name: " + name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment