| Author |
ArrayList Implementation
|
Remaan Rem
Ranch Hand
Joined: Mar 04, 2010
Posts: 36
|
|
Hi Everyone ;
In fact am having problems with creating class based on an array-based class. The class should be implemented using
Arraylist class.
So : my question is : do I have to create an array ?
if so what will be the benefit of it ?
Do I have to use any of these statements :
List <DictEntry> ListDictionary = new ArrayList <DictEntry>();
ArrayList D = new ArrayList ();
|
 |
salvin francis
Ranch Hand
Joined: Jan 12, 2009
Posts: 915
|
|
First of all Welcome to CodeRanch !
as I see, your naming conventions for the variables is bad,
eg:
Could you explain this statement so that i can help you better ?:
... creating class based on an array-based class. The class should be implemented using Arraylist class.
|
My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
|
 |
Remaan Rem
Ranch Hand
Joined: Mar 04, 2010
Posts: 36
|
|
Thanks a lot for welcoming me =) ..
The Assignment is asking to create a new class based on an existing class. The old (existing) one implemented using array data structure , the new one should be implemented using ArrayList. So, I am not very sure what importing statements should I have.
Remaan >
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Remaan Rem wrote:
The Assignment is asking to create a new class based on an existing class. The old (existing) one implemented using array data structure , the new one should be implemented using ArrayList. So, I am not very sure what importing statements should I have.
Although ArrayList has "array" as part of its name -- ArrayList and arrays are completely different. And hence, are used differently.
There is no simple generic cut-n-paste solution. You will need to go through the code, and logically convert it.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Remaan Rem
Ranch Hand
Joined: Mar 04, 2010
Posts: 36
|
|
So what will be the correct statement ?
List <DictEntry> ListDictionary = new ArrayList <DictEntry>();
|
 |
Wouter Oet
Saloon Keeper
Joined: Oct 25, 2008
Posts: 2700
|
|
|
The statement is correct however the Java Naming convention states that variables should start with a lower-case character.
|
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
|
 |
Remaan Rem
Ranch Hand
Joined: Mar 04, 2010
Posts: 36
|
|
Ok.. but does it serve the aim of the the new class ?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Remaan Rem wrote:
Ok.. but does it serve the aim of the the new class ?
We don't know how your old class uses arrays. We don't know how you plan to convert the arrays to use arraylists. I don't see how we can tell you whether a line of code can "serve the aim" of a new class. And even if we could, how can we do it better than someone who is going to do the conversion?
Henry
|
 |
Remaan Rem
Ranch Hand
Joined: Mar 04, 2010
Posts: 36
|
|
Ya I agree with you.
The old class - has an array which is a dictionary filled with elements of type (DictEntry) .
What I meant by " serve the aim" is : to create a new arrayList object to be used
instead of the old array, ( serving as dictionary).
Thank you =)
|
 |
 |
|
|
subject: ArrayList Implementation
|
|
|