Re: Finding Max and Min values from string args

It seems like the args passed to the Arrays.asList() method was treated like it was a primitive integers. What version of Java are you using?

Btw, the main method of your java class should have the String[] as the parameter to make it executable.

Hi,
my java is java6, I did it in eclipse
and I made "String[]" to "Integer[]" for the original starter of the thread 'mortus' because he wanted to find the maximum values of the arguments
and line 5 containing "Integer[]" didn't show an error in eclipse with java 6
thx,
dhilip

Re: Arrays and Collection

w.r.t. the question: how can the minimum of a bunch of Strings ever be an int? Know what you're doing before you blindly try to copy a piece of code that you don't understand.

Jos

this was in an old thread
he was asking to find maximum of the arguments given to a class
and someone moved this post to a new thread by the time you were hearing to "clubbed to death" (not concerned if it is not from england and it is from hollywood anyways)

Re: Arrays and Collection

Originally Posted by noobplus

this was in an old thread
he was asking to find maximum of the arguments given to a class
and someone moved this post to a new thread by the time you were hearing to "clubbed to death" (not concerned if it is not from england and it is from hollywood anyways)

bunch of Integer[] not Strings

Not in your example; they're a bunch of Strings and the Collections.min( ... ) method tries to return a String; you can't weazle yourself out of it: your example was simply as wrong as can be; no excuses.

See the API documentation for the Arrays.asList(T ... a) method; it doesn't understand an int[] as a bunch of ints; the work around is to use an Integer[] intarray instead; b.t.w. Eclipse would've told you so.

Re: Arrays and Collection

Originally Posted by JosAH

See the API documentation for the Arrays.asList(T ... a) method; it doesn't understand an int[] as a bunch of ints; the work around is to use an Integer[] intarray instead; b.t.w. Eclipse would've told you so.

Jos

eclipse didn't ask me to convert it to Integer[] , i updated eclipse yesterday
-edited: I mean it gave option only for "String[]"

Re: Arrays and Collection

Sorry, you were right Jos :) The method that require a parameter to implement the java.lang.Comparable is the Collections.min(...) / Collections.max(...) and not the Arrays.asList(...) method.

No need to say sorry; I just want to keep this thread as tidy as possible because the OP of this thread sprays around that much (irrelevant) nonsense that this thread can't be properly answered and closed anymore.

Re: Arrays and Collection

Originally Posted by JosAH

No need to say sorry; I just want to keep this thread as tidy as possible because the OP of this thread sprays around that much (irrelevant) nonsense that this thread can't be properly answered and closed anymore.