Printing Out appended list

S

subhabangalore

Dear Group,

If I try to append the strings in sb within a loop, where strings are getting generated from loop, --this part is getting fine, but the problem is how I can take out the print of the "sb" portion.

for (loop condition) {
StringBuilder sb = new StringBuilder();
sb.append("some string");
. . .
sb.append(anotherString);
}

If any one of the esteemed members can kindly suggest.

Regards,
Subhabrata.
 
M

markspace

Dear Group,

If I try to append the strings in sb within a loop, where strings are
getting generated from loop, --this part is getting fine, but the
problem is how I can take out the print of the "sb" portion.

for (loop condition) { StringBuilder sb = new StringBuilder();
sb.append("some string"); . . . sb.append(anotherString); }

I don't understand what is being asked. What is "take out the print"?

What does System.out.println( sb ); give you? What do you want different?
 
E

Eric Sosman

Dear Group,

If I try to append the strings in sb within a loop, where strings are getting generated from loop, --this part is getting fine, but the problem is how I can take out the print of the "sb" portion.

for (loop condition) {
StringBuilder sb = new StringBuilder();
sb.append("some string");
. . .
sb.append(anotherString);
}

This pseudocode shows no printing at all, so I guess you have
already found a way to "take out the print." What "print" are you
talking about, and why do you want to get rid of it?

Maybe if you showed actual code instead of pseudocode it would
be easier for us to understand your intent.
 
R

Roedy Green

for (loop condition) {
StringBuilder sb = new StringBuilder();
sb.append("some string");
. . .
sb.append(anotherString);
}

I am making a wild guess that what you want has nothing to do with
putting ink on paper.

String result = sb.toString();
 
R

Roedy Green

This pseudocode shows no printing at all, so I guess you have
already found a way to "take out the print." What "print" are you
talking about, and why do you want to get rid of it?

I think he means "extract the answer from the StringBuilder" analogous
to printing out the final result of some calculation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top