Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

ArrayList Implementation

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ();
 
Bartender
Posts: 2880
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 >
 
author
Posts: 23908
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what will be the correct statement ?

List <DictEntry> ListDictionary = new ArrayList <DictEntry>();
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Henry Wong
author
Posts: 23908
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 =)
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic