Hello everyone I am new here, so I hope I don't get a "fine" of 10 posts if this question is not proper for this forum anyway, here is my problem. I am new to java, thus still very confused on classes methods interfaces etc etc but trying to learn it all.. I have in one folder a selectionSort I wrote in a package called utilities as Arrays.java I made sure to put in package utilities; at the top. the code I have written is:
etc Now in my main program I have written to test my sort to see if it works (it is in a different folder) I have written:
My compilation error says: selectionSort(java.lang.Comparable) in utilities.Arrays cannot be applied to (int) I am confused.. I thought that when you use Comparable, that it means the input must be something that can be compared (such as ints)... can anyone explain how to fix this and why do i get this error? Thank you )
I changed the arrays to Integer... but now i get a compilation error that says: data[i] = Integer.parseInt(line); incompatible types Now I know data[i] is of Integer (cause I changed it) and I know the right side the parseint turns it into int... and I know int is a type of Integer, so how come this now doesn't work?
also.. trying this: data[i] = Integer(line); gives me the error: cannot resolve symbol symbol: method Integer (java.lang.String) location: class Testing my logic, was that array data is Integer, and the input comes in as a String, so changing it to Integer should work... I am confused ><
It compiled!!! thank you! finally after hours I got it compiled! how come I need new? hmm now when I go to run it i get "exception in thread "main" java.lang.NoSuchMethodError: main" but at least I got it compiled I still have huge smile on my face
*cheers* i got it to run i needed to change from int to String in my main... to this :
when i execute, it asks for the numbers, i go to enter a number and hit enter, and i get error message- arraoutofbounds..but now I can debug and work through the logic of my sort and finally be productive again thank you again...!
Colin: yeah, I need to read up more on int and Integer... i am still a bit hazy on what the relationship is between the two. I didn't know there was none... although i did know int was a primitive and Integer object, I thought int was a type of Integer.. but just now goes to show you I really need to understand the real meanings behind primitive and Object, which I am still ignorant of >< Also, need to figure out how to implement code in the correct syntax.. like for example sometimes you have something.something(); or you have something(something); those are the next to things on my list to try and master.. that is after I have this selectionsort debugged...
Right! We're on it! Let's get to work tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss