Op Sun, 20 Apr 2008 12:44:22 +0200 schreef Roedy Green =
<see_website@[EMAIL PROTECTED]
>:
> On Sat, 19 Apr 2008 00:05:37 +0200, "Boudewijn Dijkstra"
> <usenet@[EMAIL PROTECTED]
> wrote, quoted or indirectly quoted
> someone who said :
>
>> Or to do less string manipulation
>
> I can hardly imagine a case where that would be possible, unless you
> mean precomputing hunks of strings or in someway doing the string
> manipulation more efficiently.
Compare
float f; // distance in parsecs
System.out.printf("Distance is %3.2f parsecs.\n", f);
versus
int i; // distance in centiparsecs
String s =3D String.valueOf(i);
int dot =3D s.length() - 2;
System.out.printf("Distance is %s.%s parsecs.\n", s.substring(0, dot), =
=
s.substring(dot));
..
Compare
System.out.printf("Distance is %d parsecs.\n", d);
versus
System.out.print("Distance is ");
System.out.print(d);
System.out.println(" parsecs.");
..
Compare
initialisation:
Label myLabel =3D new Label();
execution:
myLabel.setText(String.format("Distance is %d parsecs.", d));
versus
initialisation:
Label myLabel1 =3D new Label("Distance is ");
Label myLabel2 =3D new Label();
Label myLabel3 =3D new Label(" parsecs.");
execution:
myLabel2.setText(String.valueOf(d));
..
-- =
Gemaakt met Opera's revolutionaire e-mailprogramma: =
http://www.opera.com/mail/


|