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.
if you swap the parameter and the literal, you can avoid unnecessary NPE ;) Good luck with your studies!
This is a good solution, but not universal :( To fix it, you need to use System.lineSeparator() or System.getProperty("line.separator")
Good luck in your studies! =)
Whenever possible, use switch is the best practice. Firstly, readability, and secondly, switch works more efficiently than if - else chains, since with if else the performer does not know in advance which condition will suit him, everything is calculated in runtime, but when using switch, the performer almost instantly chooses what came up according to the condition :) Good luck in your studies!
You are absolutely right, there is no need for this
The best practice is to write such constructions in reverse:
word.equals("") -> "".equals(word)
Why? Because this way we exclude NullPointerException, because "" will never be null, but word does not give such guarantees :) Good luck in learning!
It seems to me that returning Integer.MIN_VALUE is not the most obvious things that the method can do if it does not find the desired value. 0 or -1 would be more appropriate, IMHO :)
Conscious variable names are a sign of professionalism. Keep it up! :)
This is not a project where a full-fledged solution is required, but in any case it is done really competently
According to the condition of the problem, the length of the array is guaranteed to be > 1, in the examples it can be seen that the first element in the incoming array is "thrown out", this is logical, because checking for i % 0 will not make sense. That's why we start the sequence with 1