This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I've several classes, each consisting of an assortment of Strings and each containing a function getAsArray which returns the contents of the object as a String array.
Here an example from one specific class named Asset_HP :
In the program I populate several LinkedLists , one for each class.
I'd like to craft one generic function to write out a LinkedList like so:
instead of hardcoding a Write function for each LinkedList like this specific example for one list and one class:
what do I need to make this work? Or should I be using some other approach?
Stuart Rogers wrote:what do I need to make this work?
Something other than Java, due to this line:As Gregg says, you'll need to work around the fact that Java's generics are available at compile-time only.
The variable names "lisst" and "roww" confuse me; do the extra letters have some internal significance?
Joined: Oct 02, 2008
I deliberatley misspell my variable names so they can never be confused with typenames or anything that could be construed as part of the language itself. How many times have you seen this in a textbook?
List list = new List();
or this from C++ :
typedef int LENGTH;
in Java lots of objects inherit a .length() method.
Back to the question at hand, perhaps I should suppress warnings in my IDE for that particular function and try it "as-is".
Thanks for your replies so far,