|
-
Superclass Arraylist, Subclass
Hi
I came across this forum and was wondering if i could be enlightened!
This is what i am currently doing, is it bad programming? could you sudgest a better approach?
I have a superclass which has a method to return an ArrayList "list1":
public abstract class A
{
private ArrayList list1;
public ArrayList method1()
{
return list1;
}
}
my subclass uses method1 from superclass to access the arraylist from the superclass A and print the contents from it:
public class B extends A
{
public void printlist1()
{
Iterator it = method1().iterator();
while(it.hasNext())
{
system.out.println(it.next());
}
}
}
Any help on this subject would be great
Thanks alot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks