Results 1 to 4 of 4
  1. #1
    mallorz is offline Member
    Join Date
    Jan 2014
    Posts
    97
    Rep Power
    0

    Default Cannot infer type arguments for ArrayList<>

    *** SOLVED ***

    Let me start by saying I did try to Google this but my interpretation is either not correct or I'm way off base, either way I need some guidance.

    At the beginning of one of my classes, I instantiate some List objects. For example ...

    Java Code:
    private List<> byName = null;
    ... then later, I reference this again in a method like this:

    Java Code:
    byName = new ArrayList<>(rs.getString("firstName"), rs.getString("Last Name"));
    This is where I get the error. I've tried making the list of <String>, but that didn't make a difference.

    A little help, anyone?
    Last edited by mallorz; 05-02-2014 at 03:32 AM. Reason: Solved

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Cannot infer type arguments for ArrayList<>

    Your initial List declaration should give a compilation error. And you are using ArrayList incorrectly.
    It does not take individual types as arguments. Please read the API.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Cannot infer type arguments for ArrayList<>

    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    mallorz is offline Member
    Join Date
    Jan 2014
    Posts
    97
    Rep Power
    0

    Default Re: Cannot infer type arguments for ArrayList<>

    I was getting a bit anxious - wanted to advance in my program quicker if possible. I don't think that is an issue, but I apologize if it upset you!

Similar Threads

  1. Replies: 4
    Last Post: 02-25-2015, 02:06 AM
  2. Replies: 2
    Last Post: 11-15-2012, 05:20 PM
  3. Passing Primitive Data Type Arguments
    By tariqm in forum New To Java
    Replies: 6
    Last Post: 04-15-2012, 01:58 PM
  4. Replies: 1
    Last Post: 01-26-2012, 02:21 AM
  5. Arraylist of Type T
    By blawknox04 in forum New To Java
    Replies: 1
    Last Post: 12-11-2008, 06:55 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
  •