Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Very basic problem


  • Please log in to reply

#1
Olliey2k

Olliey2k

    New Member

  • Member
  • Pip
  • 2 posts
Hello everyone :tazz:

Sorry if this sounds a rather silly question, but i am extremely new to java.

I am having a problem with my println statements. It will print out the desired information but it will be displayed twice.

Attached is the code.

If anyone could help me out with the problem in the 2 println statements in the main that would be great, is it a toString problem?

Song.java is the main.

Thanks for any help :)

Attached Files


  • 0

Advertisements


#2
ricci

ricci

    Member

  • Member
  • PipPip
  • 64 posts
Hi Olliey,

I didn't see a Song.java in your zip file. :tazz:

-Ricci
  • 0

#3
Olliey2k

Olliey2k

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
Oops :tazz: meant to say Shop.java

Working on 2 projects at the same time :)
  • 0

#4
UV_Power

UV_Power

    Member

  • Member
  • PipPipPip
  • 391 posts
I took a look, but i couldn't find the problem. :tazz:

I am pretty new to Java myself and I have had that problem before but it was only when I was using the paint or paintComponent. That doesn't seem to be the case here...

Good luck!
  • 0

#5
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 876 posts
do you still need help?

the problem is not with toString(). items are added twice due to duplicate lines of code. try commenting the following lines in Shelves.java:

		// we add in the position indexed by nextFreeLocation
		// This starts at zero
// item added twice
//	  contents[nextFreeLocation] = theItem;

		// now increment index ready for next one
//	  nextFreeLocation = nextFreeLocation + 1;

here are other duplicate lines in Shop.java:


			//Shop run1 = new Shop ();
		   //run1.runMenu();


Edited by bdlt, 16 December 2005 - 05:26 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP