So I just concluded the 'Introduction to
Java Applications' chapter in 'Java How to Program'. I'd probally be punching my computer cause of those damned environmental variables if not for the kind people here.
Anyways, one of the exercises in the end of the chapter is to put together an app that collects two numbers, then give the; sum, difference, product and quotient.
I put this together and it worked thankfully:
After it ran, I was wondering how I could shorten the length of the code, so I tried this:
I tried it out, and it worked. YAY ME, but I was wondering, which is more efficient.
I concluded the second one because there is no need to store the four solutions. As a result the first one ties up memory that could otherwise be used one something else. Am I right in this assumption? I know this is a meaningless app, and memory use means nothing for it. Just curiosity.
Thanks for your time =)