Creating an ArrayList

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onlyme5
    New Member
    • Sep 2007
    • 1

    #1

    Creating an ArrayList

    Good day,

    Firstly I feel I must apologise, I understand that what I'm about to ask may appear to frustrate some of you who may be more experienced, however, I just don't have a clue, I can't get my head around Java, I've tried, I've read books, attended lectures and surfed the net... I just don't get it.

    On to my question.

    my understanding creating an arraylist is as follows

    ArrayList<NAME> MyList = new Array List <NAME>));

    yet when I input this in my programme my compiler said t was incorrect.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by onlyme5
    Good day,

    Firstly I feel I must apologise, I understand that what I'm about to ask may appear to frustrate some of you who may be more experienced, however, I just don't have a clue, I can't get my head around Java, I've tried, I've read books, attended lectures and surfed the net... I just don't get it.

    On to my question.

    my understanding creating an arraylist is as follows

    ArrayList<NAME> MyList = new Array List <NAME>));

    yet when I input this in my programme my compiler said t was incorrect.
    What happens if you do this instead?

    [code=java]
    ArrayList<NAME> MyList = new ArrayList<NAME> ();
    [/code]

    Assuming that NAME is a type by itself. Think of a type name such as List or
    ArrayList followed by a <type> as a specialized type, i.e. only 'type' things are
    accepted as elements of the List or ArrayList.

    kind regards,

    Jos

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by onlyme5
      Good day,

      Firstly I feel I must apologise, I understand that what I'm about to ask may appear to frustrate some of you who may be more experienced, however, I just don't have a clue, I can't get my head around Java, I've tried, I've read books, attended lectures and surfed the net... I just don't get it.

      On to my question.

      my understanding creating an arraylist is as follows

      ArrayList<NAME> MyList = new Array List <NAME>));

      yet when I input this in my programme my compiler said t was incorrect.
      Because it is incorrect. You should probably burn all your books and put your lecturers on the defenestration list. They all taught you the wrong things. Get the tutorial pointed to by this page and read that.

      P.S I'll have to rename this thread to something more appropriate.

      Comment

      • vipinkrajput
        New Member
        • Sep 2007
        • 5

        #4
        Originally posted by onlyme5
        Good day,

        Firstly I feel I must apologise, I understand that what I'm about to ask may appear to frustrate some of you who may be more experienced, however, I just don't have a clue, I can't get my head around Java, I've tried, I've read books, attended lectures and surfed the net... I just don't get it.

        On to my question.

        my understanding creating an arraylist is as follows

        ArrayList<NAME> MyList = new Array List <NAME>));

        yet when I input this in my programme my compiler said t was incorrect.

        NAME must be a type.

        Comment

        Working...