I'm implementing a textparsing application. My questions arises that if I have an interface class called DocumentComponent and it contains an ArrayList of components that are initialized in the constructor and a few methods such as add, remove, and count. Will I be able to use the ArrayList of components in the overloaded classes such as sentence and word? Thanks in advance! Rick J. Katka
Hi Rick, If you define an inteface you should know that all variables defined in that interface are final. That means that you can use the values(!!!), but not change them. note that a value is something different for an object than for a primitive. Primitives values of those like int, byte, boolean etc. are unchangable. However, a object value is the refference to an object, not its inner values. This means that an object can not be replaced with any other reference, but its methods like add(), get(), count() etc. can be called and used to change its inner values. So its possible to add new elements into your arraylist even though your arraylist is final. However you can't replace the arraylist with a new instance (filled with whatever you like).