📄 javalang.doc5.html
字号:
<html>
<head>
<title>The Java Language Specification The Package java.lang </title>
</head>
<body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000>
<a href="index.html">Contents</a> | <a href="javalang.doc4.html">Prev</a> | <a href="javalang.doc6.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<hr><br>
<a name="2349"></a>
<center><h1>20.6 The Class <code>java.lang.Number</code></h1></center>
<a name="3360"></a>
The abstract class <code>Number</code> has subclasses <code>Integer</code>, <code>Long</code>, <code>Float</code>, and <code>Double</code>
which wrap primitive types, defining abstract methods to convert the represented
numeric value to <code>int</code>, <code>long</code>, <code>float</code>, and <code>double</code>.
<p><pre><a name="2350"></a>public abstract class <code><b>Number</b></code> {
<a name="2351"></a> public abstract int <code><b>intValue</b></code>();
<a name="1142"></a> public abstract long <code><b>longValue</b></code>();
<a name="1143"></a> public abstract float <code><b>floatValue</b></code>();
<a name="1144"></a> public abstract double <code><b>doubleValue</b></code>();
<a name="1147"></a>}
</pre><a name="3376"></a>
<p><font size=+1><strong>20.6.1 </strong> <code>public abstract int <code><b>intValue</b></code>()</code></font>
<p>
<a name="3433"></a>
The general contract of the <code>intValue</code> method is that it returns the numeric value
represented by this <code>Number</code> object after converting it to type <code>int</code>.
<p><a name="4102"></a>
Overridden by <code>Integer</code> <a href="javalang.doc6.html#4213">(§20.7.8)</a>, <code>Long</code> <a href="javalang.doc7.html#1393">(§20.8.8)</a>, <code>Float</code> <a href="javalang.doc8.html#1475">(§20.9.12)</a>, and <code>Double</code> <a href="javalang.doc9.html#1520">(§20.10.11)</a>.<p>
<a name="3434"></a>
<p><font size=+1><strong>20.6.2 </strong> <code>public abstract long <code><b>longValue</b></code>()</code></font>
<p>
<a name="24622"></a>
The general contract of the <code>longValue</code> method is that it returns the numeric value
represented by this <code>Number</code> object after converting it to type <code>long</code>.
<p><a name="4144"></a>
Overridden by <code>Integer</code> <a href="javalang.doc6.html#1330">(§20.7.9)</a>, <code>Long</code> <a href="javalang.doc7.html#1394">(§20.8.9)</a>, <code>Float</code> <a href="javalang.doc8.html#1476">(§20.9.13)</a>, and <code>Double</code> <a href="javalang.doc9.html#1521">(§20.10.12)</a>.<p>
<a name="3384"></a>
<p><font size=+1><strong>20.6.3 </strong> <code>public abstract float <code><b>floatValue</b></code>()</code></font>
<p>
<a name="24626"></a>
The general contract of the <code>floatValue</code> method is that it returns the numeric
value represented by this <code>Number</code> object after converting it to type <code>float</code>.
<p><a name="4160"></a>
Overridden by <code>Integer</code> <a href="javalang.doc6.html#1331">(§20.7.10)</a>, <code>Long</code> <a href="javalang.doc7.html#1395">(§20.8.10)</a>, <code>Float</code> <a href="javalang.doc8.html#1477">(§20.9.14)</a>, and <code>Double</code> <a href="javalang.doc9.html#1522">(§20.10.13)</a>.<p>
<a name="3412"></a>
<p><font size=+1><strong>20.6.4 </strong> <code>public abstract double <code><b>doubleValue</b></code>()</code></font>
<p>
<a name="24630"></a>
The general contract of the <code>doubleValue</code> method is that it returns the numeric
value represented by this <code>Number</code> object after converting it to type <code>double</code>.
<p><a name="4176"></a>
Overridden by <code>Integer</code> <a href="javalang.doc6.html#1332">(§20.7.11)</a>, <code>Long</code> <a href="javalang.doc7.html#1396">(§20.8.11)</a>, <code>Float</code> <a href="javalang.doc8.html#1478">(§20.9.15)</a>, and <code>Double</code> <a href="javalang.doc9.html#1523">(§20.10.14)</a>.<p>
<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javalang.doc4.html">Prev</a> | <a href="javalang.doc6.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<p>
<font size=-1>Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)<br>
<i><a href="jcopyright.doc.html">Copyright © 1996 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a>
</font>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -