salvin francis

Bartender
+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Mumbai
Cows and Likes
Cows
Total received
100
In last 30 days
4
Total given
131
Likes
Total received
300
Received in last 30 days
11
Total given
153
Given in last 30 days
6
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

Carey Brown wrote:...

[Nitpick on]
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.
[Nitpick off]
2 days ago

wayne brandon wrote:...


I would find it very confusing for a variable named space to have no spaces. Maybe you meant to have an empty space instead ?

Campbell Ritchie wrote:...How woyuld you get “C R” out of my name? The only number literals permitted are 1, 0, and −1.


I think it can be done without literals too with the magic of streams.
2 days ago
The code you posted:

creates an empty array. Hence accessing any location would give you an index out of bounds.
3 days ago
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".
1 week ago
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).
1 week ago
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.
2 weeks ago
A couple of points from my end.
  • Even a method that has a void return type can have return statement(s)
  • A finally block has precedence over the return statement and can even have a return of it's own.
  • 2 weeks ago
    (Replying to an old thread)

    This can be solved using a single line of code. I tested my solution and it passed all the tests on that site. Hint : Use Regex with replaceAll. I'll not post the complete solution here.
    2 weeks ago
    I think Wikipedia is more suited for such information: Java (programming language)
    2 weeks ago

    Ron McLeod wrote:

    I see what you did there  
    That's a great way of ensuring that at least one parameter is passed!
    3 weeks ago

    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  
    3 weeks ago
    Or use reduce:
    3 weeks ago