Java Reference
In-Depth Information
public
public class
class CopyConstructorDemo
CopyConstructorDemo {
public
public static
void main ( String [] args ) {
CopyConstructorDemo object1 = new
static void
new CopyConstructorDemo ( 123 , "Hello" );
CopyConstructorDemo object2 = new
new CopyConstructorDemo ( object1 );
iif (! object1 . equals ( object2 )) {
System . out . println ( "Something is terribly wrong..." );
}
System . out . println ( "All done." );
}
private
private int
int number ;
private
private String name ;
/** Default constructor */
public
public CopyConstructorDemo () {
}
/** Normal constructor */
public
public CopyConstructorDemo ( int
int number , String name ) {
this
this . number = number ;
this
this . name = name ;
}
/** Copy Constructor */
public
public CopyConstructorDemo ( CopyConstructorDemo other ) {
this
this . number = other . number ;
this
this . name = other . name ;
}
// hashCode() and equals() not shown
Using Shutdown Hooks for Application Cleanup
Problem
You want some cleanup performed when your application shuts down.
Solution
Use the shutdown hook.
Search WWH ::




Custom Search