— Scott McNealy, Sun Microsystems Chairman, President and ceo


% [argument number][flags][width][.precision] type



Download 40,57 Mb.
Pdf ko'rish
bet283/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   279   280   281   282   283   284   285   286   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

%
[argument number][flags][width][.precision]
type
We’ll get to this later... 
it lets you say WHICH 
argument if there’s more 
than one. (Don’t worry 
about it just yet.)
These are for 
special formatting 
options like inserting 
commas, or putting 
negative numbers in 
parentheses, or to 
make the numbers 
left justified. 
This defines the 
MINIMUM number 
of characters that 
will be used. That’s 
*minimum* not 
TOTAL. If the number 
is longer than the 
width, it’ll still be used 
in full, but if it’s less 
than the width, it’ll be 
padded with zeroes.
You already know 
this one...it defines 
the precision. In 
other words, it 
sets the number 
of decimal places. 
Don’t forget to 
include the “.” in 
there.
Type is mandatory 
(see the next page) 
and will usually be 
“d” for a decimal 
integer or “f” for 
a floating point 
number.
%
[argument number][flags][width][.precision]
type
format(“%
,6.1f
”, 42.000);
There’s no “argument number” 
specified in this format String, 
but all the other pieces are there.
format 
specifier


numbers 
and
statics
you are here
4
299
The only required specifier is for TYPE
Although type is the only required specifier, remember that if you do put 
in anything else, type must always come last! There are more than a dozen 
different type modifiers (not including dates and times; they have their own 
set), but most of the time you’ll probably use %d (decimal) or %f (floating 
point). And typically you’ll combine %f with a precision indicator to set the 
number of decimal places you want in your output.
format(

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   279   280   281   282   283   284   285   286   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish