Re: Writing apps for Windows platform in Java? Why?
- From: Scirious <scirious@xxxxxxxxxxxx>
- Date: Sun, 25 Jun 2006 16:33:15 -0500
Both are poor programming in their respective languages. Java also has
the StringBuilder class that is a lot better to use concatenation. The
code would be the folloing for the optimal usage:
Java:
StringBuilder sb = new StringBuilder("a");
for (int i = 0; i < 30000; i++) {
sb.append("a");
}
textArea.setText(sb.toString());
C#
StringBuilder sb = new StringBuilder("a");
for (int i = 0; i < 30000; i++) {
sb.Append("a");
}
textArea.Text = sb.ToString();
With the code above both run so fast that I can't measure with the
resources Ihave. However, notice that I put the toString()/ToString()
outside the loop.If I set the text of the textarea inside the loop with
StringBuilder, none of the codes end before I decide to stop it by
force.
.
- Follow-Ups:
- Re: Writing apps for Windows platform in Java? Why?
- From: G . T .
- Re: Writing apps for Windows platform in Java? Why?
- References:
- Writing apps for Windows platform in Java? Why?
- From: Von Clubusev
- Re: Writing apps for Windows platform in Java? Why?
- From: Scirious
- Re: Writing apps for Windows platform in Java? Why?
- From: G . T .
- Writing apps for Windows platform in Java? Why?
- Prev by Date: Re: Writing apps for Windows platform in Java? Why?
- Next by Date: Re: Writing apps for Windows platform in Java? Why?
- Previous by thread: Re: Writing apps for Windows platform in Java? Why?
- Next by thread: Re: Writing apps for Windows platform in Java? Why?
- Index(es):