Skip to content

Instantly share code, notes, and snippets.

@pablohdzvizcarra
Created April 1, 2022 19:00
Show Gist options
  • Save pablohdzvizcarra/03f8a7ad4d4cc4d90c17ff793c16d4c8 to your computer and use it in GitHub Desktop.
Save pablohdzvizcarra/03f8a7ad4d4cc4d90c17ff793c16d4c8 to your computer and use it in GitHub Desktop.
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