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.
In order to prevent bugs in more complicated situations like this, you should strive not to learn imperative coding style at all. Almost all languages do that kind of work for you out of the box - in Java it's streams. When you start coding like this, you most certainly will produce bugs.
In this particular case you already produced a bug: what happens if I call this function with an int array of size 0?
I usally do code like this as i learn the language. But i hope to figure out other ways as i learn more of java.
But what do you mean by "dreaded bugs"? It just looks like a simple "brute force" solution to me.
(btw your missing a "do" before your "it" in your finall sentence)
This is neither "clever" nor a "best practice". I always wonder who rates these solutions.
All this is, is straight forward error prone and to be avoided imperative code. Used in production this will eventually lead to all of our dreaded bugs.
DO NOT IT THIS WAY. Never.