• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

> cannot be applied to int,Java,Lang.Object??!!

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my code....


ok...i try to judge a string to a string, and its being gay, the i tried to convert the array to a int, and it was still gay!1

i need mucho help!, thank you..
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, I'm assuming you're using Java 1.5, with all the autoboxing. Correct?

Anyway, to the point.
Your List is a List with Integer objects. You add ints, but Java internally creates Integer objects for you.
f on the other hand is a String. There is no > defined for String, only compareTo. That won't work with Integer and String though.

You should either make an int / Integer from f and then keep using >, or store Strings in the List instead and use compareTo(). Keep in mind that this will use lexicographical comparison: 10 < 2 for instance.


Can you please tell us what you want to do?
 
J. Fox
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah sorry, creating a method that will take an arraylist and data as parameters, and store the data in the arraylist in ascending order.

so you would do(im assuming), insert(mylist,25);
its a program for my CSII class.

I thought an ArrayList automatically stores objects of strings, so i thought taking the ArrayList A, and converting it to an int, or vice versa with the data, that it would work, but i guess not...

so if you could give me a better explanation in lamens, i would much appreciate it. thanks again.
[ November 16, 2005: Message edited by: Billy Goat ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Billy Goat"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any List, including ArrayList, stores Objects (in Java 1.5 you can set which type of Object), not only Strings.
You want to store ints, so the Integer wrapper class would fit best:
This code can have duplicate values.

If you don't want duplicate values you should use a SortedSet like TreeSet. This already keeps Integers in order so you just add an Integer without all the looking up of the index. Then use java.util.Iterator to iterate over the elements.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic