The Artima Developer Community
Sponsored Link

Java Answers Forum
Unable to print found element in array

1 reply on 1 page. Most recent reply: Apr 9, 2004 1:17 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Emma Roberts

Posts: 1
Nickname: paddywhist
Registered: Apr, 2004

Unable to print found element in array Posted: Apr 9, 2004 8:14 AM
Reply to this message Reply
Advertisement
Can anyone PLEASE help! It's driving me round the bend. I have set up an array asking the user to enter the array value. There are several methods that all work well except one - find element in array.


I think it is finding the element, but I am unable to print the details of the found element, it prints the details of the last element added. The find method asks the user to enter the string value to be found in the array, returning either Found with the details printed or not found.


The methods that work let me add an element to the array, delete an element from the array & fills the gaps (which to add to the confusion uses the find method), and print all element details in array.


I can provide the code if anyone can help, but it is part of a large menu so didn't want to overload the question!


Any suggestions will be very gratefully received.


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Unable to print found element in array Posted: Apr 9, 2004 1:17 PM
Reply to this message Reply
Try trim down to just the part that is trying to find the element you seek and/or the part that is displaying that element and post just that (remember to use the java markup tags!).

By the way, that should be a simple method, not mixed in with your menu code. If it isn't maybe this is a good time to do that little refactoring exercise and probably while doing that, you'll discover the problem yourself as a side benefit.

Additionally, if you construct yourself a little unit test that tests finding an element, that will probably help make your code more modular and decoupled, while solving the problem. I'm not saying that you should go off and learn some unit testing framework right now, as you seem to be trying to finish your assignment for a nearby deadline, but you can write one test method and call it manually. Then later, when you have more time and less stress, you can learn a unit testing framework like Aritma SuiteRunner (http://www.artima.com/suiterunner/) or junit (http://www.junit.org/index.htm).

Flat View: This topic has 1 reply on 1 page
Topic: Help with toHexString Previous Topic   Next Topic Topic: trapping images

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use