Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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
  • 875 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