Results 1 to 2 of 2
  1. #1
    katturv is offline Member
    Join Date
    Oct 2010
    Posts
    18
    Rep Power
    0

    Default please check the program

    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.Collections;
    import java.util.Comparator;

    public class arraylist
    {
    public static void main(String[] args)
    {
    ArrayList<Integer,String> mylist = new ArrayList<Integer,String>();

    mylist.add(1,"1");
    mylist.add(2,"1");
    mylist.add(3,"1");
    mylist.add(4,"1");


    System.out.println("Iterating through ArrayList elements...");

    Iterator itr = mylist.iterator();
    while(itr.hasNext())

    System.out.println(itr.next());
    }
    }

    what is wrong with the program:::
    it is showing:wrong number of type arguments;

    thanks
    Last edited by katturv; 01-08-2011 at 04:31 PM.

  2. #2
    AcousticBruce is offline Senior Member
    Join Date
    Dec 2010
    Location
    Indiana
    Posts
    202
    Rep Power
    5

    Default

    17 posts and still no code tags? Please use code tags. Look how nice they look. :)

    First issue I see right away is this <Integer, String> use this instead <Object>

    Since Object allows you to use all types of objects...
    Java Code:
     ArrayList<Object> mylist = new ArrayList<Object>();


    and im not sure about

    Java Code:
    itr.next()
    itr?

Similar Threads

  1. java program check
    By ryamz in forum New To Java
    Replies: 4
    Last Post: 07-22-2010, 05:55 AM
  2. Replies: 10
    Last Post: 05-01-2010, 10:51 PM
  3. Check box tag
    By elizaabru in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-26-2008, 03:37 PM
  4. CRC check program 1 error
    By javakid9000 in forum New To Java
    Replies: 1
    Last Post: 03-19-2008, 06:04 AM
  5. how to check available resources in java program
    By lealea in forum New To Java
    Replies: 3
    Last Post: 08-13-2007, 09:35 PM

Posting Permissions

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