/* * @topic T11350 Cloneable class demo I * @brief main( ) uses cloned Product object -- shallow copy */ package products; public class ProductsMain { public static void main( String[] args ) { Product book = new Product( 123, "Horror", 5.95 ); try { Product book2 = ( Product ) book.clone(); if ( book.getDescription() == book2.getDescription() ) { System.out.println( "The copy is shallow" ); } book2.setDescription( "Computers" ); System.out.println( book.getDescription() ); System.out.println( book2.getDescription() ); } catch ( CloneNotSupportedException ex ) { } }//main }//class ProductsMain