Re: Beginner Projects
- From: Pseudo Silk Kimono <misplacedchildhoods@xxxxxxxxxxxxx>
- Date: Thu, 30 Aug 2007 15:28:00 +0000 (UTC)
On Thu, 30 Aug 2007 03:58:39 GMT, Roedy Green expounded upon us in
comp.lang.java.help :
On Wed, 29 Aug 2007 21:23:06 +0000 (UTC), Pseudo Silk Kimono
<Pseudo_Silk_Kimono@xxxxxxxxxxxxx> wrote, quoted or indirectly
quoted someone who said :
if ( (intValue % 2) == 0 )
this.isEven = true;
else
this.isEven = false;
I would collapse this to:
this.isEven = ( intValue %2 ) == 0;
Most likely isEven could be made local. Then you could shorten
it further to:
isEven = ( intValue & 1 ) == 0;
I just threw that in for a lark to see if I could get it working.
Your program looks like its a bit complex to be a "simple beginner
project". Mine works and when I tested the times, I threw a huge int
at it and it still only took one second to return an answer for me.
My first attempt was one class, with a main and a method, but I
realized that it wasn't very object-oriented, which is why I switched
to the class/tester program you see before you.
What does this mean? "Most likely isEven could be made local"
.
- References:
- Beginner Projects
- From: Pseudo Silk Kimono
- Re: Beginner Projects
- From: Roedy Green
- Beginner Projects
- Prev by Date: Re: Beginner Projects
- Next by Date: Newbie - JAR question
- Previous by thread: Re: Beginner Projects
- Next by thread: Newbie - JAR question
- Index(es):