ObjectCopy.java - This program uses the Stock class's copy...

This preview shows page 1 out of 1 page.

/**This program uses the Stock class's copy methodto create a copy of a Stock object.*/public class ObjectCopy{public static void main(String[] args){// Create a Stock object.Stock company1 = new Stock("XYZ", 9.62);// Declare a Stock variableStock company2;// Make company2 reference a copy of the object// referenced by company1.company2 = company1.copy();// Display the contents of both objects.System.out.println("Company 1:\n" + company1);

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture