Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: I need a different approach - suggestions please Date: Mon, 25 Jun 2012 18:10:27 -0700 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 26 Jun 2012 01:10:30 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="Aj4gkJnboYPtscrbpd0V8g"; logging-data="29534"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tVa+3ThlRlot9D1Jj4KefaY/JssO59fk=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Cancel-Lock: sha1:9k+kKKlblyq45GSMLk540/Yu7Wg= Xref: csiph.com comp.lang.java.programmer:15592 On 6/25/2012 4:47 PM, bilsch wrote: > Thanks for the help. I could swear I tried that first but got error > messages about static and non-static conflict problem. i will be taking > Java in fall quarter. Right now I'm working from "Learn Java in 24 > Hours" I thought up the calculator project myself. Thanks again. It was the Q1 parts of your code that really tipped me off. I suppose you could be planning on a future Q1 class, but it did make it look like you where taking a course over the summer. BTW, another way to improve you code is to watch the big cascades of if-else statements. For example this: if (btn == ".") {strng1 += btn;} else if (btn == "0") {strng1 += btn;} else if (btn == "1") {strng1 += btn;} else if (btn == "2") {strng1 += btn;} else if (btn == "3") {strng1 += btn;} else if (btn == "4") {strng1 += btn;} else if (btn == "5") {strng1 += btn;} else if (btn == "6") {strng1 += btn;} else if (btn == "7") {strng1 += btn;} else if (btn == "8") {strng1 += btn;} else if (btn == "9") {strng1 += btn;} could all just be strng1 += btn; because you don't do anything different for the different cases. Copy-paste statement like this should be avoid, because it creates relatively low value redundancy. Try to combine common cases into one block. It's easier to go back and modify later.