The Artima Developer Community
Sponsored Link

Java Answers Forum
need help with a loop

1 reply on 1 page. Most recent reply: Feb 3, 2003 12:00 PM by Jo

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
ben

Posts: 57
Nickname: loftty
Registered: Oct, 2002

need help with a loop Posted: Feb 3, 2003 10:09 AM
Reply to this message Reply
Advertisement
Hello again
The code below prints out this
[7,4,2,1,0]
addr1, id, phone, lastname, firstname
[9,8,6,5,3]
town, addr2, postcode, county, country


for (int ii2=0;ii2 < results2.size(); ii2++) {
vv2 = (Vector)results2.elementAt(ii2);
ste2 = vv2.toString();
stb2 = new StringBuffer(ste2);
stb12 = new StringBuffer();
int is = stb2.length();
int is2 = is-2;
int is3 = is-1;
stb2.replace(0,1,"");
stb2.replace(is2,is3,"");
for(int i222 = 0; i222 < vv2.size(); i222++){
stb12.append(",");
stb12.append("?");
}
stb12.replace(0,1,"");
System.out.println(stb2);
vv = (Vector)results.get(ii2);
System.out.println(vv);
}


my problem now is that i want to put another loop inside of it so that my code will print this
ben
[7,4,2,1,0]
addr1, id, phone, lastname, firstname
alex
[9,8,6,5,3]
town, addr2, postcode, county, country
this is my loop.

//names holds ben, alex.
for (i = 0; i < names.size(); i++){
String name = (String)results1.get(i);
System.out.println(name);
}

thanks
ben


Jo

Posts: 3
Nickname: jodedor
Registered: Feb, 2003

Re: need help with a loop Posted: Feb 3, 2003 12:00 PM
Reply to this message Reply
> Hello again
> The code below prints out this
> [7,4,2,1,0]
> addr1, id, phone, lastname, firstname
> [9,8,6,5,3]
> town, addr2, postcode, county, country
>
>
> for (int ii2=0;ii2 < results2.size(); ii2++) {
> vv2 = (Vector)results2.elementAt(ii2);
> ste2 = vv2.toString();
> stb2 = new StringBuffer(ste2);
> stb12 = new StringBuffer();
> int is = stb2.length();
> int is2 = is-2;
> int is3 = is-1;
> stb2.replace(0,1,"");
> stb2.replace(is2,is3,"");
> for(int i222 = 0; i222 < vv2.size(); i222++){
> stb12.append(",");
> stb12.append("?");
> }
> stb12.replace(0,1,"");
> System.out.println(stb2);
> vv = (Vector)results.get(ii2);
> System.out.println(vv);
> }
>
>

> my problem now is that i want to put another loop inside
> of it so that my code will print this
> ben
> [7,4,2,1,0]
> addr1, id, phone, lastname, firstname
> alex
> [9,8,6,5,3]
> town, addr2, postcode, county, country
> this is my loop.
>
> //names holds ben, alex.
> for (i = 0; i < names.size(); i++){
> String name = (String)results1.get(i);
> System.out.println(name);
> }
>

> thanks
> ben

Not sure what you want to do but you dont need another loop inside, it appears that the logic to call the name should go on the outside. That is identify the user, then find the data. Perhaps you should post some pseudocode that illustrates what it is that you are trying to acomplish.

Flat View: This topic has 1 reply on 1 page
Topic: coding error-can nay one help me Previous Topic   Next Topic Topic: Another question about Runtime.exec()

Sponsored Links



Google
  Web Artima.com   

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