avatar
a simple question# Java - 爪哇娇娃
l*r
1
A beginner's question:
how can I create a string of 5 0s in Java?
Thanx!
avatar
g*g
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!

avatar
m*t
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.
avatar
g*g
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);

avatar
t*c
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);

avatar
m*t
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 换来换去 有什么意义?

avatar
t*c
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... ;-)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。