Last active
June 6, 2016 00:02
-
-
Save caoakleyii/e03ec9b9c13400fbfffde7a9d482cb48 to your computer and use it in GitHub Desktop.
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
public class CloneMaker { | |
public void MakeClone() { | |
MyClone cloneA = new MyClone(); | |
System.out.printLn(cloneA.fullName); // OUTPUT: "Daniel Waldron"; | |
System.out.printLn(cloneA.firstName); // Won't compile, because of it's lack of access firstName is not defined. | |
System.out.printLn(cloneA.lastName); // Won't compile because of it's lack of access lastName is not defined. | |
cloneA.SayFirstName(); // OUTPUT: "Daniel"; | |
cloneA.SayLastName(); // OUTPUT: "Waldron"; | |
} | |
} |
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
public class MyClone { | |
private string firstName = "Daniel"; | |
private String lastName = "Waldron"; | |
public String fullName; | |
public MyClone(){ | |
fullName = firstName + lastName; | |
} | |
public static void main(String[] args) { | |
} | |
public void SayFirstName() { | |
System.out.printLn(firstName); | |
// this can read firstname | |
} | |
public void SayLastName() { | |
System.out.printLn(lastName); | |
// this can read lastname | |
} | |
} |
/*
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
*/
package myclone;
/**
*
-
@author daniel.waldron
*/
public class MyClone {
private String firstName = "Daniel";
private String lastName = "Waldron";
public String fullName;public MyClone(){
fullName = firstName + lastName;
}
public static void main(String[] args) {}
public void SayFirstName() {
System.out.println(firstName);
// this can read firstname
}public void SayLastName() {
System.out.println(lastName);
// this can read lastname
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run:
C:\Users\daniel.waldron\AppData\Local\NetBeans\Cache\8.0.2\executor-snippets\run.xml:48:
Cancelled by user.
BUILD FAILED (total time: 1 second)