Hi,
I am learning about Inner Classes and have encountered a compilation error that I am having trouble figuring out.
I have created a class called Invoice (which is the outer, enclosing class) and within this, I have added an inner class called InvoiceItem:
I have created another class called UseInvoice, which creates two objects. One object is an instance of the Invoice class and the other is an instance of the InvoiceItem class.
The Invoice class compiles without any problem, however when trying to compile the UseInvoice class, I get the following error:
C:\Documents and Settings\JGehlot\Desktop\Java Videos\Java Files\Inner_Classes>javac UseInvoice.java
UseInvoice.java:3: package Invoice does not exist
import Invoice.*;
^
UseInvoice.java:16: cannot find symbol
symbol : class InvoiceItem
location: class UseInvoice
InvoiceItem myInvItem = myInvoice.new InvoiceItem(1,345, "Toy Train", 2) ;
^
2 errors
C:\Documents and Settings\JGehlot\Desktop\Java Videos\Java Files\Inner_Classes>
Note: UseInvoice.class and Invoice.class and Invoice$InvoiceItem.class are in the same folder (C:\Documents and Settings\JGehlot\Desktop\Java Videos\Java Files\Inner_Classes).
Could someone tell me what I am doing wrong? I think its something to do with the use of the import Invoice.*; statement at the top of the UseInvoice file.
Thanks