Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with ArrayList ? ....

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with ArrayList ? ....

    Please help me I need the code for this question. Here it is....

    Define a class named ArrayList. This class represents a list of objects and supports random access to its objects via a numeric index position. Thus, it should contain an array of Object. For this exercise, include an instance variable for the array, an instance variable to track the number of objects currently accessible in the array (its logical size), three constructors, and a toString method. The default constructor should create an array of five objects, all initially null. The second constructor expects an integer parameter. This constructor uses this integer as the initial length of the array. The third constructor expects an array of objects as an argument. It copies these objects to a new array instance variable of the same length. the count (logical size) of the accessible objects should be initialized appropriately in each constructor. The toString method builds and returns a string containing the string representations of the objects currently accessible in the array. When the logical size is 0, this is the empty string.

    If anyone knows how to do this please help?....


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Help with ArrayList ? ....

    Begin by reading the question closely and making sure you understand it. Specifically this means that you should know what methods and constructors your class will have including the types of their arguments and, for methods, the type they return. Additionally you should know what each method or constructor is supposed to do - it's a good idea to indicate this with a javadoc comment (probably just a sentence) accompanying each method and constructor.

    Once you know what you are doing you can begin to implement each of the methods and constructors. At this point you might find it useful to have a main() method (possibly in another class) which tests each method and constructor to ensure that it does what it is documented to do.

    -----

    I doubt whether anyone is going to write your code for you. But if you are unsure about what the question means, post the skeletal code indicated above and someone is sure to say if they think you have left something out, or misinterpreted the intent of the question.

    If, having implemented a method or constructor, you find that it doesn't perform exactly as documented, again post your code so you have a specific question that can be addressed.

Similar Threads

  1. How to use an ArrayList and what is its advantage over array?
    By JavaPF in forum Java SE API Tutorials
    Replies: 4
    Last Post: December 21st, 2011, 04:44 AM
  2. private Map<String, ArrayList> xlist = new HashMap<String, ArrayList>();
    By Scotty in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 21st, 2011, 08:37 AM
  3. Ordering ArrayList by 3 conditions as you add to ArrayList
    By aussiemcgr in forum Collections and Generics
    Replies: 4
    Last Post: July 13th, 2010, 02:08 PM
  4. [SOLVED] Extracting an How to ArrayList from an ArrayList and convert to int??
    By igniteflow in forum Collections and Generics
    Replies: 2
    Last Post: August 16th, 2009, 01:11 PM
  5. How to use an ArrayList and what is its advantage over array?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: May 17th, 2009, 01:12 PM

Tags for this Thread