Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Forked from anonymous/gist:5459345
Created April 25, 2013 12:49
Show Gist options
  • Save tbuehlmann/5459450 to your computer and use it in GitHub Desktop.
Save tbuehlmann/5459450 to your computer and use it in GitHub Desktop.
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