wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes logic check please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "logic check please" Watch "logic check please" New topic
Author

logic check please

Tim Batts
Greenhorn

Joined: Aug 09, 2010
Posts: 10
Brand spankin new rookie here. Entered the following test class and my output is incorrect. e2.count is supposed to end at 10 but I get 24 when I execute it. I've desk-checked 3 times and I get the 10 I'm supposed to, but output is still 24. Any ideas?

Tim Batts
Greenhorn

Joined: Aug 09, 2010
Posts: 10
sorry about the indent format... the indent was there when I pasted the code to the forum, but disappeared when I submitted my post
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Evidently you didn't notice the "Code" button above the box you posted in. Try it again: first click the Code button, then paste your code between the tags which it generates.
Tim Batts
Greenhorn

Joined: Aug 09, 2010
Posts: 10
Paul Clapham wrote:Evidently you didn't notice the "Code" button above the box you posted in. Try it again: first click the Code button, then paste your code between the tags which it generates.


Thanks... I'm new to the forum scene as well
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Without the code we'd be guessing.
Tim Batts
Greenhorn

Joined: Aug 09, 2010
Posts: 10
I found it:

Echo e2=e1;

should be

Echo e2=new Echo();

to create a new instance rather than duplicate the original count
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Glad you got it working--but still post all the relevant code next time... Thanks :)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: logic check please
 
Similar Threads
Classes and Projects Chapter 2 of Head start JAVA pool puzzle
A Puzzle...sort of
Need help interpreting this script
Can someone explain how this code works?
The value is not what i expected