I am currently experimenting with Strings in Java.
For example you have a string "1234 Hello 56789"
and now you want to calculate the average of the max and min value, which is (1234/5678)/2 = 58023
.
How do you do that?
I tried Integer.parseInt
which gives me an error.
I tried replaceAll("[^0-9]", "")
which does not get me the min and max and therefore the avg. It outputs 123456789 which I do not want.
I also tried replaceAll("[^0-9]", "").split("\\D+")
which just gives me 1234 56789
, but I don't know how to get the min and max.