The Artima Developer Community
Sponsored Link

Java Answers Forum
why does my code print out the same word 12 times

2 replies on 1 page. Most recent reply: Nov 25, 2002 11:56 AM by Charles Bell

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 2 replies on 1 page
jason

Posts: 7
Nickname: bibs
Registered: Nov, 2002

why does my code print out the same word 12 times Posted: Nov 25, 2002 9:03 AM
Reply to this message Reply
Advertisement
i have this in my code but it prints out the element what i want but it will print it 12 times which is how many elements are in the vector how do i get it to print it out only once?
for (Enumeration e = v.elements();e.hasMoreElements();) {
String se = (String)e.nextElement();
String s1 = (String)v.get(1);

System.out.println(s1);


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: why does my code print out the same word 12 times Posted: Nov 25, 2002 11:52 AM
Reply to this message Reply
System.out.println((String)v.elementAt(1));

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: why does my code print out the same word 12 times Posted: Nov 25, 2002 11:56 AM
Reply to this message Reply
or

System.out.println((String)v.get(1));

or

System.out.println((String)v.toArray()[1]);

Flat View: This topic has 2 replies on 1 page
Topic: resultset from a store proc Previous Topic   Next Topic Topic: Confused and need help desperately

Sponsored Links



Google
  Web Artima.com   

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