418 Object-Based Programming Chapter 8 1 (Unable to start debugging on the web server) // Fig.

418 Object-Based Programming Chapter 8 1 // Fig. 8.16: PackageDataTest.java 2 // Classes in the same package (i.e., the same directory) can 3 // use package access data of other classes in the same package. 4 5 // Java extension packages 6 import javax.swing.JOptionPane; 7 8 public class PackageDataTest { 9 10 // Java extension packages 11 public static void main( String args[] ) 12 { 13 PackageData packageData = new PackageData(); 14 15 // append String representation of packageData to output 16 String output = 17 “After instantiation:n” + packageData.toString(); 18 19 // change package access data in packageData object 20 packageData.number = 77; 21 packageData.string = “Good bye”; 22 23 // append String representation of packageData to output 24 output += “nAfter changing values:n” + 25 packageData.toString(); 26 27 JOptionPane.showMessageDialog( null, output, 28 “Demonstrating Package Access”, 29 JOptionPane.INFORMATION_MESSAGE ); 30 31 System.exit( 0 ); 32 } 33 34 } // end class PackageDataTest 35 36 // class with package access instance variables 37 class PackageData { 38 int number; // package access instance variable 39 String string; // package access instance variable 40 41 // constructor 42 public PackageData() 43 { 44 number = 0; 45 string = “Hello”; 46 } 47 48 // convert PackageData object to String representation 49 public String toString() 50 { 51 return “number: ” + number + ” string: ” + string; 52 } 53 Fig. 8.16 Package access to members of a class (part 1 of 2). Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/3/01
Note: If you are looking for high quality webhost to host and run your jsp application check Vision florida web design services

Leave a Reply