📄 format.html
字号:
</TR>
</TABLE>
<A NAME="Format(java.lang.String)"><!-- --></A><H3>
Format</H3>
<PRE>
public <B>Format</B>(java.lang.String s)</PRE>
<DL>
<DD>Formats the number following <tt>printf</tt> conventions.
Main limitation: Can only handle one format parameter at a time
Use multiple Format objects to format more than one number<DD><DL>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - the format string following printf conventions
The string has a prefix, a format code and a suffix. The prefix and suffix
become part of the formatted output. The format code directs the
formatting of the (single) parameter to be formatted. The code has the
following structure
<ul>
<li> a % (required)
<li> a modifier (optional)
<dl>
<dt> + <dd> forces display of + for positive numbers
<dt> 0 <dd> show leading zeroes
<dt> - <dd> align left in the field
<dt> space <dd> prepend a space in front of positive numbers
<dt> # <dd> use "alternate" format. Add 0 or 0x for octal or hexadecimal numbers. Don't suppress trailing zeroes in general floating point format.
</dl>
<li> an integer denoting field width (optional)
<li> a period followed by an integer denoting precision (optional)
<li> a format descriptor (required)
<dl>
<dt>f <dd> floating point number in fixed format
<dt>e, E <dd> floating point number in exponential notation (scientific format). The E format results in an uppercase E for the exponent (1.14130E+003), the e format in a lowercase e.
<dt>g, G <dd> floating point number in general format (fixed format for small numbers, exponential format for large numbers). Trailing zeroes are suppressed. The G format results in an uppercase E for the exponent (if any), the g format in a lowercase e.
<dt>d, i <dd> integer in decimal
<dt>x <dd> integer in hexadecimal
<dt>o <dd> integer in octal
<dt>s <dd> string
<dt>c <dd> character
</dl>
</ul><DT><B>Throws:</B><DD>java.lang.IllegalArgumentException - if bad format</DL>
</DD>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" ID="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="printf(java.lang.String, double)"><!-- --></A><H3>
printf</H3>
<PRE>
public static void <B>printf</B>(java.lang.String fmt,
double x)</PRE>
<DL>
<DD>prints a formatted number following printf conventions<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fmt</CODE> - the format string<DD><CODE>x</CODE> - the double to print</DL>
</DD>
</DL>
<HR>
<A NAME="printf(java.lang.String, int)"><!-- --></A><H3>
printf</H3>
<PRE>
public static void <B>printf</B>(java.lang.String fmt,
int x)</PRE>
<DL>
<DD>prints a formatted number following printf conventions<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fmt</CODE> - the format string<DD><CODE>x</CODE> - the int to print</DL>
</DD>
</DL>
<HR>
<A NAME="printf(java.lang.String, long)"><!-- --></A><H3>
printf</H3>
<PRE>
public static void <B>printf</B>(java.lang.String fmt,
long x)</PRE>
<DL>
<DD>prints a formatted number following printf conventions<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fmt</CODE> - the format string<DD><CODE>x</CODE> - the long to print</DL>
</DD>
</DL>
<HR>
<A NAME="printf(java.lang.String, char)"><!-- --></A><H3>
printf</H3>
<PRE>
public static void <B>printf</B>(java.lang.String fmt,
char x)</PRE>
<DL>
<DD>prints a formatted number following printf conventions<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fmt</CODE> - the format string<DD><CODE>x</CODE> - the character to print</DL>
</DD>
</DL>
<HR>
<A NAME="printf(java.lang.String, java.lang.String)"><!-- --></A><H3>
printf</H3>
<PRE>
public static void <B>printf</B>(java.lang.String fmt,
java.lang.String x)</PRE>
<DL>
<DD>prints a formatted number following printf conventions<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fmt</CODE> - the format string<DD><CODE>x</CODE> - a string to print</DL>
</DD>
</DL>
<HR>
<A NAME="atoi(java.lang.String)"><!-- --></A><H3>
atoi</H3>
<PRE>
public static int <B>atoi</B>(java.lang.String s)</PRE>
<DL>
<DD>Converts a string of digits (decimal, octal or hex) to an integer<DD><DL>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - a string<DT><B>Returns:</B><DD>the numeric value of the prefix of s representing a base 10 integer</DL>
</DD>
</DL>
<HR>
<A NAME="atol(java.lang.String)"><!-- --></A><H3>
atol</H3>
<PRE>
public static long <B>atol</B>(java.lang.String s)</PRE>
<DL>
<DD>Converts a string of digits (decimal, octal or hex) to a long integer<DD><DL>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - a string<DT><B>Returns:</B><DD>the numeric value of the prefix of s representing a base 10 integer</DL>
</DD>
</DL>
<HR>
<A NAME="atof(java.lang.String)"><!-- --></A><H3>
atof</H3>
<PRE>
public static double <B>atof</B>(java.lang.String s)</PRE>
<DL>
<DD>Converts a string of digits to a <tt>double</tt><DD><DL>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - a string</DL>
</DD>
</DL>
<HR>
<A NAME="format(double)"><!-- --></A><H3>
format</H3>
<PRE>
public java.lang.String <B>format</B>(double x)</PRE>
<DL>
<DD>Formats a <tt>double</tt> into a string (like sprintf in C)<DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the number to format<DT><B>Returns:</B><DD>the formatted string<DT><B>Throws:</B><DD>java.lang.IllegalArgumentException - if bad argument</DL>
</DD>
</DL>
<HR>
<A NAME="format(int)"><!-- --></A><H3>
format</H3>
<PRE>
public java.lang.String <B>format</B>(int x)</PRE>
<DL>
<DD>Formats an integer into a string (like sprintf in C)<DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the number to format<DT><B>Returns:</B><DD>the formatted string</DL>
</DD>
</DL>
<HR>
<A NAME="format(long)"><!-- --></A><H3>
format</H3>
<PRE>
public java.lang.String <B>format</B>(long x)</PRE>
<DL>
<DD>Formats a long integer into a string (like sprintf in C)<DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the number to format<DT><B>Returns:</B><DD>the formatted string</DL>
</DD>
</DL>
<HR>
<A NAME="format(char)"><!-- --></A><H3>
format</H3>
<PRE>
public java.lang.String <B>format</B>(char c)</PRE>
<DL>
<DD>Formats a character into a string (like sprintf in C)<DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the value to format<DT><B>Returns:</B><DD>the formatted string</DL>
</DD>
</DL>
<HR>
<A NAME="format(java.lang.String)"><!-- --></A><H3>
format</H3>
<PRE>
public java.lang.String <B>format</B>(java.lang.String s)</PRE>
<DL>
<DD>Formats a string into a larger string (like sprintf in C)<DD><DL>
<DT><B>Parameters:</B><DD><CODE>x</CODE> - the value to format<DT><B>Returns:</B><DD>the formatted string</DL>
</DD>
</DL>
<HR>
<A NAME="main(java.lang.String[])"><!-- --></A><H3>
main</H3>
<PRE>
public static void <B>main</B>(java.lang.String[] a)</PRE>
<DL>
<DD>a test stub for the format class</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" ID="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#FFFFFF" ID="NavBarCell1Rev"> <FONT ID="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../overview-tree.html"><FONT ID="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../deprecated-list.html"><FONT ID="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../index-all.html"><FONT ID="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" ID="NavBarCell1"> <A HREF="../help-doc.html"><FONT ID="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
<A HREF="../corejava/Day.html"><B>PREV CLASS</B></A>
<A HREF="../corejava/RandomIntGenerator.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" ID="NavBarCell2"><FONT SIZE="-2">
<A HREF="../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Format.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" ID="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -