Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23030 > unrolled thread
| Started by | subhabangalore@gmail.com |
|---|---|
| First post | 2013-03-21 07:59 -0700 |
| Last post | 2013-03-21 14:06 -0700 |
| Articles | 6 — 5 participants |
Back to article view | Back to comp.lang.java.programmer
Printing Out appended list subhabangalore@gmail.com - 2013-03-21 07:59 -0700
Re: Printing Out appended list markspace <markspace@nospam.nospam> - 2013-03-21 08:09 -0700
Re: Printing Out appended list lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-21 15:22 +0000
Re: Printing Out appended list Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-03-21 11:56 -0400
Re: Printing Out appended list Roedy Green <see_website@mindprod.com.invalid> - 2013-03-21 18:21 -0700
Re: Printing Out appended list Roedy Green <see_website@mindprod.com.invalid> - 2013-03-21 14:06 -0700
| From | subhabangalore@gmail.com |
|---|---|
| Date | 2013-03-21 07:59 -0700 |
| Subject | Printing Out appended list |
| Message-ID | <47637551-543f-49fc-8165-41de869e6a8f@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Date | 2013-03-21 08:09 -0700 |
| Message-ID | <kif7nc$nr3$1@dont-email.me> |
| In reply to | #23030 |
On 3/21/2013 7:59 AM, subhabangalore@gmail.com wrote:
> 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?
[toc] | [prev] | [next] | [standalone]
| From | lipska the kat <"nospam at neversurrender dot co dot uk"> |
|---|---|
| Date | 2013-03-21 15:22 +0000 |
| Message-ID | <ad-dnaSVvNk7uNbMnZ2dnUVZ8madnZ2d@bt.com> |
| In reply to | #23030 |
On 21/03/13 14:59, subhabangalore@gmail.com wrote:
> 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);
> }
Difficult to know exactly what you mean here but I'll take a shot
StringBuilder sb = new StringBuilder();
for(condition){
sb.append("some string");
...
}
System.out.printf("%s\n", sb.toString());
--or, slightly more disturbingly --
StringBuilder buffer = new StringBuilder();
for(condition){
StringBuilder sb = new StringBuilder();
sb.append("whatever");
...
buffer.append(sb.toString());
}
System.out.printf("%s\n", buffer.toString());
can't see the point of this second example although it appears to meet
your original criteria of creating a new builder for each iteration of
the loop.
lipska
--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2013-03-21 11:56 -0400 |
| Message-ID | <kifagh$b8o$1@dont-email.me> |
| In reply to | #23030 |
On 3/21/2013 10:59 AM, subhabangalore@gmail.com wrote:
> 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.
--
Eric Sosman
esosman@comcast-dot-net.invalid
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-03-21 18:21 -0700 |
| Message-ID | <afcnk8pfjjuf90mn1c9s7g9q40tnsegrem@4ax.com> |
| In reply to | #23033 |
On Thu, 21 Mar 2013 11:56:55 -0400, Eric Sosman <esosman@comcast-dot-net.invalid> wrote, quoted or indirectly quoted someone who said : > 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. -- Roedy Green Canadian Mind Products http://mindprod.com Every method you use to prevent or find bugs leaves a residue of subtler bugs against which those methods are ineffectual. ~ Bruce Beizer Pesticide Paradox
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2013-03-21 14:06 -0700 |
| Message-ID | <ohtmk85vj6uvn88a354374a3u35cijj9rq@4ax.com> |
| In reply to | #23030 |
On Thu, 21 Mar 2013 07:59:03 -0700 (PDT), subhabangalore@gmail.com
wrote, quoted or indirectly quoted someone who said :
> 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();
--
Roedy Green Canadian Mind Products http://mindprod.com
Every method you use to prevent or find bugs leaves a residue of subtler
bugs against which those methods are ineffectual.
~ Bruce Beizer Pesticide Paradox
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web