Results 1 to 4 of 4
  1. #1
    timkd127 is offline Member
    Join Date
    Dec 2008
    Posts
    41
    Rep Power
    0

    Default problem with implementing list

    I have fulfilled all of the abstract methods except for the toString(). I made an instance of the array to test it with a capacity of 16 and put the values
    0-9 in the array indices of 0-9. When this method returns the String its returning (0,1,3,5,7,9). Any help is appreciated.
    Java Code:
    public String toString(){
    		StringBuffer sB=new StringBuffer();
    		
    		sB.append(list[0]);
    		
    		for(int i=1;i<list.length;i++){
    			sB.append("\n"+list[i]);
    			i++;
    		}
    		
    		return sB.toString();
    	}

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    you've got i++ twice in your for loop, once in the conditions at the top, and once in the body. Get rid of it in the body as you really shouldn't be manipulating a for loop's indices in the body of the loop.

  3. #3
    timkd127 is offline Member
    Join Date
    Dec 2008
    Posts
    41
    Rep Power
    0

    Default

    o man i cant believe i didnt catch that. i looked at it for a solid hour haha. thanks for the help.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. [Hurry!!!] Got a problem in Array List...
    By kidwave1 in forum New To Java
    Replies: 7
    Last Post: 11-24-2008, 04:17 AM
  2. validation problem in list box
    By rakesh_n_mehta in forum Web Frameworks
    Replies: 0
    Last Post: 10-14-2008, 08:47 AM
  3. Array List problem
    By kurenai in forum New To Java
    Replies: 2
    Last Post: 06-25-2008, 08:30 AM
  4. Array List Problem
    By khamuruddeen in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 09:10 AM
  5. list problem
    By fareez in forum New To Java
    Replies: 3
    Last Post: 06-28-2007, 11:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •