Created
April 1, 2022 19:00
-
-
Save pablohdzvizcarra/03f8a7ad4d4cc4d90c17ff793c16d4c8 to your computer and use it in GitHub Desktop.
copy constructor object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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