I would expect at least 2 guard conditions for a method like that: a null check and a range check. Unless the method is expected to throw a StringIndexOutOfBoundsException and a NullPointerException. Even then, there should be documentation to indicate that.
If your aim is to only run music and do some basic mixing on chromebooks, then I would suggest looking into Html based solutions as well. You can research on "Web Audio API". Your Application would be quite easily ported to multiple platforms without any changes. If the Chromebooks are running on a LAN, and you have a client-server model, you can deploy it on a local running webserver like tomcat or jetty".
Just wanted to point out, if the number has a negative value, then the modulus operator(%) would give you a negative value for every iteration. This may not be what OP is looking for.
@OP, the modulus operator (%) gives the division remainder. This works well for +ve numbers %10 since when dividing by 10, the last digit is always the remainder and that's why n % 10 gives you the last digit. Another use for % is when checking for even and odd numbers using 2 as divisor.
Next, the division (/) works in the above case because of loss of precison. If we have a number (say 203) and we divide it by 10, it would return 20.3. But, since we are using int to store it's value, the 0.3 is ignored and the result is just 20. This effectively shortens the number by a digit.
I think that Strings are best suited for this kind of requirement. Assuming that you're only interested if the digit exists in the second number, then String's contains method is good, else you can you indexOf method. However, you might want to consider handing numbers beginning with a 0 first (octal numbers).
Do you mean that you are having issues pasing regex while using eclipse ?
There is a config called "Escape text when pasting into a string literal" in eclipse. I think it should be under Preferences > Java > Editor > Typing.
Rob Spoor wrote:...but sum can definitely be useful...
I got curious and checked 1.8 source. I found that the code for sum for Integer, Long, Double is exactly the same (i.e. return a+b;). I also found that min, max are just delegating calls to Math.min and Math.max.
It's good to know that these methods exist