Discussion:
[問題] 關於 output format
(时间太久无法回复)
what u doing
2007-03-20 15:03:32 UTC
Permalink
像 c code 裡 printf(" %6d ", a );
^^^^^^^

這種東西要怎麼用Java表現出來?

我有查到Sytem.out.format的東西,但是不會用

希望各位大大指導一下


--

War does not determine who is right. War determines who is left.

--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.7.59
骨頭
2007-03-20 15:37:03 UTC
Permalink
※ 引述《darkmiz (what u doing)》之銘言:
: 像 c code 裡 printf(" %6d ", a );
: ^^^^^^^
: 這種東西要怎麼用Java表現出來?
: 我有查到Sytem.out.format的東西,但是不會用
: 希望各位大大指導一下


<code>
int a=15;
System.out.printf(" %6d " ,a);
</code>

as simple as what you see,

Java also support
String.format(String fomat,Object... values);

API:
http://0rz.tw/b62sv

notice: since 1.5

--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...

--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.27.68

Loading...