-
-
Save tbuehlmann/5459450 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
class HelloObject | |
{ | |
String greeting; | |
HelloObject(String st) | |
{ | |
greeting=st; | |
} | |
HelloObject(HelloObject obj) | |
{ | |
//initialize the object's greeting to the same of the obj parameter | |
} | |
void speak() | |
{ | |
System.out.println(greeting); | |
} | |
} | |
class thirty4 | |
{ | |
public static void main (String[] args) | |
{ | |
HelloObject hello1=new HelloObject("A Greeting!"); | |
HelloObject hello2=new HelloObject(hello1); | |
hello1.speak(); | |
hello2.speak(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment