long.html

来自「API資料大全」· HTML 代码 · 共 1,168 行 · 第 1/4 页

HTML
1,168
字号
<DL><DD>Creates a string representation of the long argument as an unsigned integer in base&nbsp;2. <p> The unsigned long value is the argument plus 2<sup>64</sup> if  the argument is negative; otherwise, it is equal to the argument.  <p> If the unsigned magnitude is zero, it is represented by a single zero character <tt>'0'</tt> (<tt>'&392;u0030'</tt>); otherwise, the  first character of the representation of the unsigned magnitude  will not be the zero character. The characters <tt>'0'</tt>  (<tt>'&#92;u0030'</tt>) and <tt>'1'</tt> (<tt>'&#92;u0031'</tt>)  are used as binary digits.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>i</CODE> - a long.<DT><B>Returns:</B><DD>the string representation of the unsigned long value          represented by the argument in binary (base&nbsp;2).<DT><B>Since: </B><DD>JDK 1.0.2</DD></DL></DD></DL><HR><A NAME="toString(long)"><!-- --></A><H3>toString</H3><PRE>public static <A HREF="../../java/lang/String.html">String</A> <B>toString</B>(long&nbsp;i)</PRE><DL><DD>Returns a new String object representing the specified integer.  The argument is converted to signed decimal representation and  returned as a string, exactly as if the argument and the radix  10 were given as arguments to the  <A HREF="../../java/lang/Long.html#toString(long, int)"><CODE>toString(long, int)</CODE></A> method that takes two arguments.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>i</CODE> - a <code>long</code> to be converted.<DT><B>Returns:</B><DD>a string representation of the argument in base&nbsp;10.</DL></DD></DL><HR><A NAME="parseLong(java.lang.String, int)"><!-- --></A><H3>parseLong</H3><PRE>public static long <B>parseLong</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;s,                             int&nbsp;radix)                      throws <A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></PRE><DL><DD>Parses the string argument as a signed <code>long</code> in the  radix specified by the second argument. The characters in the  string must all be digits of the specified radix (as determined by  whether <code>Character.digit</code> returns a  nonnegative value), except that the first character may be an  ASCII minus sign <code>'-'</code> (<tt>'&#92;u002d'</tt> to indicate  a negative value. The resulting <code>long</code> value is returned.  <p> Note that neither <tt>L</tt> nor <tt>l</tt> is permitted to appear at  the end of the string as a type indicator, as would be permitted in  Java programming language source code - except that either <tt>L</tt>  or <tt>l</tt> may appear as a digit for a radix greater than 22. <p> An exception of type <tt>NumberFormatException</tt> is thrown if any of the following situations occurs: <ul> <li>The first argument is <tt>null</tt> or is a string of length zero.  <li>The <tt>radix</tt> is either smaller than      <A HREF="../../java/lang/Character.html#MIN_RADIX"><CODE>Character.MIN_RADIX</CODE></A> or larger than      <A HREF="../../java/lang/Character.html#MAX_RADIX"><CODE>Character.MAX_RADIX</CODE></A>.  <li>The first character of the string is not a digit of the     specified <tt>radix</tt> and is not a minus sign <tt>'-'</tt>      (<tt>'&#92;u002d'</tt>).  <li>The first character of the string is a minus sign and the     string is of length 1.  <li>Any character of the string after the first is not a digit of     the specified <tt>radix</tt>.  <li>The integer value represented by the string cannot be     represented as a value of type <tt>long</tt>.  </ul><p> Examples: <blockquote><pre> parseLong("0", 10) returns 0L parseLong("473", 10) returns 473L parseLong("-0", 10) returns 0L parseLong("-FF", 16) returns -255L parseLong("1100110", 2) returns 102L parseLong("99", 8) throws a NumberFormatException parseLong("Hazelnut", 10) throws a NumberFormatException parseLong("Hazelnut", 36) returns 1356099454469L </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - the <code>String</code> containing the                     <code>long</code>.<DD><CODE>radix</CODE> - the radix to be used.<DT><B>Returns:</B><DD>the <code>long</code> represented by the string argument in             the specified radix.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></CODE> - if the string does not contain a               parsable integer.</DL></DD></DL><HR><A NAME="parseLong(java.lang.String)"><!-- --></A><H3>parseLong</H3><PRE>public static long <B>parseLong</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;s)                      throws <A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></PRE><DL><DD>Parses the string argument as a signed decimal <code>long</code>.  The characters in the string must all be decimal digits, except  that the first character may be an ASCII minus sign  <code>'-'</code> (<code>&#92;u002d'</code>) to indicate a negative  value. The resulting long value is returned, exactly as if the argument and the radix <tt>10</tt> were given as arguments to the <A HREF="../../java/lang/Long.html#parseLong(java.lang.String, int)"><CODE>parseLong(String, int)</CODE></A> method that takes two arguments.  <p> Note that neither <tt>L</tt> nor <tt>l</tt> is permitted to appear  at the end of the string as a type indicator, as would be permitted in Java programming language source code.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - a string.<DT><B>Returns:</B><DD>the <code>long</code> represented by the argument in decimal.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></CODE> - if the string does not contain a               parsable <code>long</code>.</DL></DD></DL><HR><A NAME="valueOf(java.lang.String, int)"><!-- --></A><H3>valueOf</H3><PRE>public static <A HREF="../../java/lang/Long.html">Long</A> <B>valueOf</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;s,                           int&nbsp;radix)                    throws <A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></PRE><DL><DD>Returns a new long object initialized to the value of the specified String. Throws an exception if the String cannot be parsed as a long. <p> The first argument is interpreted as representing a signed integer in the radix specified by the second argument, exactly as if the arguments were given to the <A HREF="../../java/lang/Long.html#parseLong(java.lang.String, int)"><CODE>parseLong(java.lang.String, int)</CODE></A>  method that takes two arguments. The result is a <tt>Long</tt> object  that represents the integer value specified by the string.  <p> In other words, this method returns a <tt>Long</tt> object equal  to the value of: <blockquote><pre> new Long(Long.parseLong(s, radix)) </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - the <code>String</code> containing the                     <code>long</code>.<DD><CODE>radix</CODE> - the radix to be used.<DT><B>Returns:</B><DD>a newly constructed <code>Long</code> initialized to the             value represented by the string argument in the specified             radix.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></CODE> - If the <code>String</code> does not               contain a parsable <code>long</code>.</DL></DD></DL><HR><A NAME="valueOf(java.lang.String)"><!-- --></A><H3>valueOf</H3><PRE>public static <A HREF="../../java/lang/Long.html">Long</A> <B>valueOf</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;s)                    throws <A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></PRE><DL><DD>Returns a new long object initialized to the value of the specified String. Throws an exception if the String cannot be parsed as a long. The radix is assumed to be 10. <p> The argument is interpreted as representing a signed decimal integer, exactly as if the argument were given to the  <A HREF="../../java/lang/Long.html#parseLong(java.lang.String)"><CODE>parseLong(java.lang.String)</CODE></A> method that takes one argument).  The result is a <code>Long</code> object that represents the integer  value specified by the string.  <p> In other words, this method returns a <tt>Long</tt> object equal to  the value of: <blockquote><pre> new Long(Long.parseLong(s)) </pre></blockquote><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - the string to be parsed.<DT><B>Returns:</B><DD>a newly constructed <code>Long</code> initialized to the             value represented by the string argument.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></CODE> - If the <code>String</code> does not               contain a parsable <code>long</code>.</DL></DD></DL><HR><A NAME="decode(java.lang.String)"><!-- --></A><H3>decode</H3><PRE>public static <A HREF="../../java/lang/Long.html">Long</A> <B>decode</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;nm)                   throws <A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></PRE><DL><DD>Decodes a <code>String</code> into a <code>Long</code>.  Accepts decimal, hexadecimal, and octal numbers, in the following formats: <pre>     [-]        decimal constant     [-] 0x     hex constant     [-] #      hex constant     [-] 0      octal constant </pre> The constant following an (optional) negative sign and/or "radix specifier" is parsed as by the <code>Long.parseLong</code> method with the specified radix (10, 8 or 16).  This constant must be positive or a NumberFormatException will result.  The result is made negative if first character of the specified <code>String</code> is the negative sign.  No whitespace characters are permitted in the <code>String</code>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>nm</CODE> - the <code>String</code> to decode.<DT><B>Returns:</B><DD>the <code>Long</code> represented by the specified string.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NumberFormatException.html">NumberFormatException</A></CODE> - if the <code>String</code> does not            contain a parsable long.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Long.html#parseLong(java.lang.String, int)"><CODE>parseLong(String, int)</CODE></A></DL></DD></DL><HR><A NAME="byteValue()"><!-- --></A><H3>byteValue</H3><PRE>public byte <B>byteValue</B>()</PRE><DL><DD>Returns the value of this Long as a byte.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#byteValue()">byteValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="shortValue()"><!-- --></A><H3>shortValue</H3><PRE>public short <B>shortValue</B>()</PRE><DL><DD>Returns the value of this Long as a short.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#shortValue()">shortValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Since: </B><DD>JDK1.1</DD></DL></DD></DL><HR><A NAME="intValue()"><!-- --></A><H3>intValue</H3><PRE>public int <B>intValue</B>()</PRE><DL><DD>Returns the value of this Long as an int.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#intValue()">intValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the <code>long</code> value represented by this object is          converted to type <code>int</code> and the result of the          conversion is returned.</DL></DD></DL><HR><A NAME="longValue()"><!-- --></A><H3>longValue</H3><PRE>public long <B>longValue</B>()</PRE><DL><DD>Returns the value of this Long as a long value.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#longValue()">longValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the <code>long</code> value represented by this object.</DL></DD></DL><HR><A NAME="floatValue()"><!-- --></A><H3>floatValue</H3><PRE>public float <B>floatValue</B>()</PRE><DL><DD>Returns the value of this Long as a float.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#floatValue()">floatValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the <code>long</code> value represented by this object is

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?