File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Quick question about interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Quick question about interfaces" Watch "Quick question about interfaces" New topic
Author

Quick question about interfaces

Rick Katka
Greenhorn

Joined: Feb 22, 2004
Posts: 7
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
Rikko Verrijzer
Ranch Hand

Joined: Jul 22, 2003
Posts: 34
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).

Hope this helps?
Rikko
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Will I be able to use the ArrayList of components in the overloaded classes such as sentence and word?
What do you mean by "overloaded class"?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Quick question about interfaces
 
Similar Threads
Collections - ArrayList and Vector
2D Array of Strings as Output parameters
Does jsf accept ArrayList?
Struts 2: Action objects not passed to JSP
Return mutable collection?