Results 1 to 4 of 4
  1. #1
    crosswind is offline Member
    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Default Comparsion between Integer and Int

    Hi,

    currently making a game whereby i am using Vectors. i tried to make a comparsion between two types Integer and Int.

    e.g
    if(CPchosen.elementAt(i) == Id)

    CPchosen is my vector and Id is initialzed as a int. However when i build this setting i get this error,

    operator == cannot be applied to java.lang.Object,int
    if(CPchosen.elementAt(i) == Id)


    I understand that its becos i am trying to make comparsion between 2 diferent types. So I tried to initialize my vector to become an int

    Vector<int>CPchosen = new Vector<int>();

    But by doing so, i get the following error.

    generics are not supported in -source 1.3
    (use -source 5 or higher to enable generics)

    Hence i seek help in resolving this issue, anyone can help?

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Cast CPchosen.elementAt(i) to Integer
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Pixio is offline Member
    Join Date
    Apr 2010
    Posts
    3
    Rep Power
    0

    Default

    generics are not supported in -source 1.3
    (use -source 5 or higher to enable generics)
    Vector<int>CPchosen = new Vector<int>();
    It's why it shows errors because u r using generics - Vector<T> - which is not available in Java 1.3.
    Last edited by Pixio; 04-15-2010 at 07:43 PM.

  4. #4
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    And unless you are really, really, really sure you want to be programming in Java 1.3, you should update to 1.5 or 1.6. If you don't know which to choose between those two, choose 1.6.

    -Gary-

Similar Threads

  1. 1 as an integer, not boolean
    By McChill in forum New To Java
    Replies: 1
    Last Post: 05-02-2009, 09:39 PM
  2. integer with leading zero?!
    By tomiu in forum New To Java
    Replies: 4
    Last Post: 04-22-2009, 09:42 PM
  3. .java files comparsion
    By rhub in forum Eclipse
    Replies: 4
    Last Post: 09-22-2008, 02:55 PM
  4. VeryLong Integer.. help
    By hey in forum New To Java
    Replies: 4
    Last Post: 12-14-2007, 09:48 PM
  5. Integer vs int
    By bugger in forum New To Java
    Replies: 1
    Last Post: 11-14-2007, 09:13 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
  •