another question
basicstampede
Posts: 214
Hello.· On pg. 57 of Javelin manual 1.0, there is a statement
System.out.println(String.valueOf(dischargeTime));
But nowhere do I see what String or valueOf does.· I can sort of figure it out, but I'm looking for some official statement of what this statement does.
Can anyone help please?
dischargeTime·was previously declared as
static int dischargeTime;
static int chargeTime;
By the way, this example declares chargeTime, but never uses it.· Any idea why not?
Thanks.
System.out.println(String.valueOf(dischargeTime));
But nowhere do I see what String or valueOf does.· I can sort of figure it out, but I'm looking for some official statement of what this statement does.
Can anyone help please?
dischargeTime·was previously declared as
static int dischargeTime;
static int chargeTime;
By the way, this example declares chargeTime, but never uses it.· Any idea why not?
Thanks.
Comments
a string representing the signed decimal value of the int. So -4 generates "-4"
Basically, it does Format.sprintf(buf,"%d",value).
The advantage of Format, is that you can use binary, octal, decimal, unsigned decimal and·hex
as the base for the generated string. Using Format.bprintf() you can even assemble strings
in the same char array.
regards peter
Then what is String?· Is that a class?· Does it belong to System class?
(You can search for valueOf in acrobat reader to find all references).
It also states the method valueOf(int) generates a temporary string
that usually is discarded once used. That may lead to out of memory error
if one is not careful.
The Format class does not have that problem at all. Because the Format
class is not part of the Javelin IDE distribution, it is not discussed in the manual.
That applies to all classes that Javelin users have developed.
regards peter