• Post Reply Bookmark Topic Watch Topic
  • New Topic

ListIterator output not whats exepcted. What am i missing?  RSS feed

 
Samuel Weston
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm supposed to write a program that
1)has an array of Strings that is then added to a List -and outputting that List
2)remove certain Strings in List1 by using a second List -and outputting the result
3)and finally, reverse the order of the Strings outputted in the last result

Problem: Eclipse is telling me that I have not imported the correct method for this program and the output is an error
.
After this, I imported the suggested import that Eclipse gave me, with the result being that I only outputted 1)and2) as a single line

What am I missing?

(Note: the "problem method" is ListIterator (all the way at bottom ListIterator<String> william = L.listIterator(L.size());
eclipse says "ListIterator cannot be resolved to a type"
and suggests (among other things) I import ListIterator.util (but doing so outputs 1)and 2) as a single line)

UPDATE: after going over the code yet again, I realized that what I thought was the problem was actually something else entirely. In case you're wondering (and because I think learning from my experience
could help someone in a similar situation): one of the pieces of code that I wrote was in fact an obsolete piece of code that I somehow copied to this class.
in addition, this piece of code resulted in an output similar to what I was looking for -in regards to the program as a whole.(the code removed certain String words from a List by using another List
-meanwhile, I was trying to remove certain words from that same List via another technique (just fyi: I also incorrectly construed my second goal ("2) above")

The Fix: I removed the obsolete code, and then proceeded to and succeeded in fixing the code with the correct "method"

 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I wrote a class named ListIterator, how would your application know to use the standard ListIterator and not another one?
 
Samuel Weston
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:If I wrote a class named ListIterator, how would your application know to use the standard ListIterator and not another one?


my update to my question should answer your question. I appreciate your time .thank you so much
 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well now, the code you posted doesn't reflect the current state of affairs. Can you please post what difficulties you're experiencing now, and the latest code example? Please do this in a new post, and don't update the original post, because that will lead to confusion.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!