Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
It's better to use Long#parseLong instead of Long#valueOf. That's because parseLong method returns long and valueOf method wraps the result in Long class, then the method unwraps it (which obviously is redundant).
mikiPP, I know this solution is old, but still some people try to solve this kata, they fail and after unlocking the solutions they see code like this which obviously is a bad source of knowledge.
Anyway, good to hear you've learned how to correctly compare two strings. :D
Katya, "==" operator tests whether two values are the same object and equals() method checks if values of these objects are the same.
If you want to know more about it, I highly recommend reading this thread: https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
You are right, but this code have a long time.I have learned it in the bad way, ty anyway!
Why to avoid?
You are trying to declare an int variable with a double value, which obviously won't work.
However, in this case it works, because compilator knows that the type of sum variable is int and it just casts it to int. Since the result of pow is an integer (double), nothing special happens, but if the result were a non-integer, then the decimal part of the method's result would be truncated (100.18 would be 100, 11.254 would be 11, 1.0 would be 1, and so on, and so on...).
I know this comment is 7 months old, but I wanted to clear it up.
In this case, using "==" to compare two strings is fine, but generally you should avoid it.