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.


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

Results 1 to 4 of 4

Thread: Not Generic; cannot be parameterized

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Thanked 0 Times in 0 Posts

    Default Not Generic; cannot be parameterized

    Hi all,

    I was provided a .class called Node.class with no .java file.

    So now I have another java file called Person that has to make use of this Node. But I get an error which says "The type Node is not generic; it cannot be parameterized with arguments <Person>"

    The java file provided to me had an import line of javax.xml.soap.Node; but im thinking i'm not supposed to be importing this node class, but instead the one i was provided? However, I've already placed it in the same package in say, netbeans but still get an error.

    E.g. Node<Person> per1 = null; //this line gives the error

    Can anyone help me out with this? Thanks!

  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Thanked 329 Times in 305 Posts

    Default Re: Not Generic; cannot be parameterized

    I'm not really sure how to explain this.

    My guess is that the Node Class provided doesnt allow you to specify the type, which is what you are doing by using the <Person> identifier. Do you have any API or a list of methods and constructors for the Node Class? Without that, there isnt much help can be provided.

    I'll give you an example for what I mean by "type" (since that probably isnt the correct word):

    When you say
    ArrayList<Person> arr = new ArrayList<Person>();
    You are identifying every object in the ArrayList as a Person Object. You are allowed to do this for ArrayLists because the ArrayList Class is an ArrayList<?> Class. That <?> allows you to specify objects within a collection as "Generics".

    You cant do the same for something like the JButton class or something.
    JButton<Person> button = new JButton<Person>();
    This will not compile because JButton doesnt allow you to attach an identifier.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: Not Generic; cannot be parameterized

    Appears the Node cannot be parametized...eg it does not use generics. Remove the generic <Person>. If the class you have uses generics, make sure your import points to the correct Node class file, you can be quite explicit if you have multiple class names:
    mypackage.Node<Person> person = null;

  4. #4
    Junior Member
    Join Date
    Sep 2010
    Thanked 0 Times in 0 Posts

    Default Re: Not Generic; cannot be parameterized

    As far as I know, the node class is a polymorphic ADT and it was specified that Node<Person> be used in place of Node as a type.

Similar Threads

  1. Generic method using an int[] argument
    By dubois.ford in forum Collections and Generics
    Replies: 2
    Last Post: March 18th, 2010, 07:18 AM
  2. [SOLVED] generic arguments, binary tree
    By vendetta in forum Collections and Generics
    Replies: 0
    Last Post: February 26th, 2010, 07:40 AM
  3. generic class
    By fireatmuself in forum Collections and Generics
    Replies: 4
    Last Post: November 17th, 2009, 06:06 AM
  4. Generic programming example
    By neo_2010 in forum Java Programming Tutorials
    Replies: 3
    Last Post: July 8th, 2009, 11:38 AM