• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayList Implementation  RSS feed

 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Bartender
Posts: 1653
37
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what will be the correct statement ?

List <DictEntry> ListDictionary = new ArrayList <DictEntry>();
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The statement is correct however the Java Naming convention states that variables should start with a lower-case character.
 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok.. but does it serve the aim of the the new class ?

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 =)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!