The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

inner class -

Posted by seba368 on October 09, 2000 at 3:11 PM

Hi all,
I saw this example in the Bruce Eckel book "thinking in java"
and looks like that your main method doesn't have to be in a public class....this class Test is an inner class that is in the public class..so is this a reason??? I always thought that the main method has to be in the public class.
..but maybe since this is inner class that is in the public class that it doesnt....please help.
thanks

class Test {
public static void main(String[] args) {
Parcel3 p = new Parcel3();
Contents c = p.cont();
Destination d = p.dest("Tanzania");
// Illegal -- can't access private class:
//! Parcel3.PContents pc = p.new PContents();
}
} ///:~
Note that since main( ) is in Test, when you want to run this program
you don�t execute Parcel3, but instead:
java Test



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us