A friend the other day (well a couple weeks back now I think) asked me to explain the following to them to confirm that they had understood what was required of them for a bit of course work they had to produce.
"Write a Java program which defines an unconstrained array of user defined length n, that contains n Random numbers and outputs those random numbers that are even numbers."
My explanation re-affirmed their understanding of the problem.
The next thing I did after our discussion was google this to see what had been put out there to help learning coders. To my amazement a near identical question had been asked on a website (not going to link to it). What annoyed me was that to see the answer I had to pay money! Hence why I won't link to the website.
As I said this annoyed me, so here I am putting a solution up that I hope people find instead of the pay walled version out there. I suppose in a way I still have that spirit from the early days of computing about sharing information etc. Which to me always seemed to be a bit hippy like. And I like that thought.
My solution (see code below) is a Java console app. Didn't want to take up too much space with all the GUI stuff, I just wanted to get straight to the core of the solution without any extra baggage.
So I apologise for not having done an exciting post, or not using the most efficient java code. But hopefully some-one out there will find the post useful.