l*r 发帖数: 34 | 1 A beginner's question:
how can I create a string of 5 0s in Java?
Thanx! | g*****g 发帖数: 34805 | 2 String a = "00000", that's it.
【在 l*r 的大作中提到】 : A beginner's question: : how can I create a string of 5 0s in Java? : Thanx!
| m******t 发帖数: 2416 | 3
Hmmm, why not something that actually justifies our salary? /grin...
StringBuilder sb = new StringBuilder("\u0020");
for (int i = 0; i < 3; i++) {
sb.append(sb.toString());
}
String rawString = sb.toString();
String truncatedString = rawString.substring(0, (int)Math.pow(2, 3) - 3);
String resultString = truncatedString.replace('\u0020', '\u0030');
System.out.println(resultString);
【在 g*****g 的大作中提到】 : String a = "00000", that's it.
| g*****g 发帖数: 34805 | 4 You should at least make a javabean to access your
precious String, using a System.out is not gonna
do the job.
【在 m******t 的大作中提到】 : : Hmmm, why not something that actually justifies our salary? /grin... : StringBuilder sb = new StringBuilder("\u0020"); : for (int i = 0; i < 3; i++) { : sb.append(sb.toString()); : } : String rawString = sb.toString(); : String truncatedString = rawString.substring(0, (int)Math.pow(2, 3) - 3); : String resultString = truncatedString.replace('\u0020', '\u0030'); : System.out.println(resultString);
| t******c 发帖数: 348 | 5 靠StringBuilder是j2se1.5刚出来的,不适合多线程。
请问搞些\u0020 \u0030 换来换去 有什么意义?
【在 m******t 的大作中提到】 : : Hmmm, why not something that actually justifies our salary? /grin... : StringBuilder sb = new StringBuilder("\u0020"); : for (int i = 0; i < 3; i++) { : sb.append(sb.toString()); : } : String rawString = sb.toString(); : String truncatedString = rawString.substring(0, (int)Math.pow(2, 3) - 3); : String resultString = truncatedString.replace('\u0020', '\u0030'); : System.out.println(resultString);
| m******t 发帖数: 2416 | 6
Oh, that's extremely important in terms of keeping the program
100% unicode conform, and hence localizable. StringBuilder
is another critical part, precisely because it's part of
J2SE 5.0, which represents the cutting edge technology we
always try to sell, er, I mean, provide value with, to our
customers.
Besides, writing code like that is the only fun I have
everyday, working with those other software engineers who
don't have any sense of humor whatsoever... ;-)
【在 t******c 的大作中提到】 : 靠StringBuilder是j2se1.5刚出来的,不适合多线程。 : 请问搞些\u0020 \u0030 换来换去 有什么意义?
| t******c 发帖数: 348 | 7
i see.
i agree with you in the unicode part.
but i won't use StringBuilder except in the circumstances
where this class is obviously better than StringBuffer.
btw, you just come to show that
you are not a boring java engineer?
lol
【在 m******t 的大作中提到】 : : Oh, that's extremely important in terms of keeping the program : 100% unicode conform, and hence localizable. StringBuilder : is another critical part, precisely because it's part of : J2SE 5.0, which represents the cutting edge technology we : always try to sell, er, I mean, provide value with, to our : customers. : Besides, writing code like that is the only fun I have : everyday, working with those other software engineers who : don't have any sense of humor whatsoever... ;-)
|
|