Subject: beginning java ch05 TryPackage
Posted By: wolfshow Post Date: 4/19/2006 9:47:59 AM
import Geometry.*;    // Import the Point and Line classes

public class TryPackage {
  public static void main(String[] args) {
    double[][] coords = { {1.0, 0.0}, {6.0, 0.0}, {6.0, 10.0},
                          {10.0,10.0}, {10.0, -14.0}, {8.0, -14.0}};
    // Create an array of points and fill it with Point objects
    Point[] points = new Point[coords.length];
    for(int i = 0; i < coords.length; i++)
      points[i] = new Point(coords[i][0],coords[i][1]);

    // Create an array of lines and fill it using Point pairs
    Line[] lines = new Line[points.length - 1];
    double totalLength = 0.0;                      // Store total line length here
    for(int i = 0; i < points.length - 1; i++) {
      lines[i] = new Line(points[i], points[i+1]); // Create a Line
      totalLength += lines[i].length();            // Add its length
      System.out.println("Line "+(i+1)+' ' +lines[i] +
                         "  Length is " + lines[i].length());
    }
    // Output the total length
    System.out.println("\nTotal line length = " + totalLength);
  }
}

why this code have the information like this:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method
Point.<init>(DD)V from class TryPackage
        at TryPackage.main(TryPackage.java:10)

Reply By: wolfshow Reply Date: 4/19/2006 9:50:22 AM
Is there anything wrong with Point.java or something else?


Go to topic 43092

Return to index page 310
Return to index page 309
Return to index page 308
Return to index page 307
Return to index page 306
Return to index page 305
Return to index page 304
Return to index page 303
Return to index page 302
Return to index page 301