🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #556

Re: Wierd system.out.println

#556
From: Allen Wallis
Date: Thu, 24 Aug 2000 00:00
63 lines
2884 bytes
Maybe some more code is needed in order to see what exactly is
happening.

I had a problem where a similar piece of code appeared to be executing
twice, I actually found that what had happened was that I had registered
two listeners for a particular event that were executing the exact peice
of code. Now this may or may not be relevant in your case, depending on
the complexity of your code, but just make sure that there is no way you
have multiple instances of the same class executing that conditional set
of code. 

cheers
Allen

Nicholas Routledge wrote:
> 
> Hi all,
> 
> I'm having this extremely frustrating problem that i can't see to fix.
> I have a method called processRequest and when called, returns a string.
> After processRequest is called, the string that is returned is assigned to a
> variable called status.
> this is what i have next,
> 
> if (status.equals("Confirm")) {
>     ...
>     System.out.println("Confirm (Y/N): ");
>     char c = (char) br.read();
>     ...
> }
> 
> else if (status.equals("Alternate")) {
>     ...
>     System.out.println("Confirm (Y/N): ");
>     char c = (char) br.read();
>     ...
> }
> .
> .
> 
> Now the problem is, the System.out.println statements in each conditional
> branch are executed TWICE for some reason.  They should only be executed
> once because the statements are not nested inside a loop.  Also, i have no
> recursion anywhere in the program.
> 
> For example, if the first branch is taken, it prints out,
> "Confirm (Y/N): "
> "Confirm (Y/N): "
> 
> Its extremely wierd but i was wondering whether anyone had any suggestions
> or whether anyone had seen this problem before?
> I can't explain it.
> 
> --
> cheers,
> Nick
> 
> =================================
> Nicholas Routledge
> ICQ#: 41114416
> Website: http://users.bigpond.com/n.routledge/
> Email: s371556@student.uq.edu.au
> =================================
Technical Details
Message-ID: <39A531CA.F0D6D466@rrsg.ee.uct.ac.za>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <s5Oo5.36404$c5.101625@newsfeeds.bigpond.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,23055c9aac63ea4a
X-Google-Attributes: gid10d6db,public
X-Google-Thread: 10a146,23055c9aac63ea4a
X-Google-Attributes: gid10a146,public
X-Google-Thread: 113ae9,23055c9aac63ea4a
X-Google-Attributes: gid113ae9,public
From: Allen Wallis <allen@rrsg.ee.uct.ac.za>
Subject: Re: Wierd system.out.println
Date: 2000/08/24
Message-ID: <39A531CA.F0D6D466@rrsg.ee.uct.ac.za>
X-Deja-AN: 661965692
Content-Transfer-Encoding: 7bit
References: <s5Oo5.36404$c5.101625@newsfeeds.bigpond.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@uct.ac.za
X-Trace: news.adamastor.ac.za 967127031 99744 137.158.128.112 (24 Aug 2000 14:23:51 GMT)
Organization: University of Cape Town
Mime-Version: 1.0
NNTP-Posting-Date: 24 Aug 2000 14:23:51 GMT
Newsgroups: aus.computers.java,comp.lang.java.help,comp.lang.java.programmer