Created
September 12, 2018 20:18
-
-
Save devDeejay/eb6af6511c1f9b7ad080729829b4b06d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class StormTrooper implements Cloneable { | |
| String color = "White"; | |
| String master = "Darth Vader"; | |
| StormTrooper() { | |
| System.out.println("Welcome to the Dark Side"); | |
| } | |
| @Override | |
| protected Object clone() throws CloneNotSupportedException { | |
| StormTrooper trooper = null; | |
| try { | |
| trooper = (StormTrooper) super.clone(); | |
| // New Object master will be the same as cloning object's Master | |
| trooper.master = this.master; | |
| } catch (CloneNotSupportedException e) { | |
| e.printStackTrace(); | |
| } | |
| return trooper; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment