#Why is it showing error
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
as said before this method does not work for primitives
afaik the only way is to box into reference types ie Integer[]
what
use Integer[] instead of int[]
https://www.baeldung.com/java-sorting-arrays#descending-order
thats how baeldung is managing that
but there are many ways to turn the ints to Integer
Which one do I replace Integer[] with? the colour code is changing to blue
its changing as variable name
yea but none of the ways are good...
yeah...
change int[] a to Integer[] a
and also
it's int[] a, not int a[] now that I see it, the second one is a legacy from C that shouldn't be used
first is a primitive type, second is a reference type, or object if you prefer
it's a bit complex
my habit from C/C++
java complex af
but to put simply, Collections.reverseOrder() is using something called generics, and generics are not supported by primitives
complex for someone who doesn't know java*
well, I guess it's complex anyway 🤔
and for whatever reason, they didn't add a method specifically to sort ints with custom order, so you have to use this inferior solution...
btw are they going to revamp/add some methods when this new generic update comes?
forgot the name
value types or smth
idk
they won't need since int will now work with generics
valhalla ?
ah ok
but will they remove the primitive specific methods then?
yeah, backwards compatibility prob
why would they remove them ?
Closed the thread due to inactivity.
If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you 👍