JDK 源码解读之 Number类



public abstract class Number implements java.io.Serializable {

  Number类有修饰符 abstract 。表明Number类定义了一些方法,并没有具体实现,需要子类自己实现,关于abstract ,quaro上一个答案写的很清晰:

    The “abstract” Keyword

  1. The keyword abstract can be used on classe declaration. For example abstract MyClassX (…);.
  2. The keyword abstract can be used on method declaration. For example abstract int f (…);.
  3. When a class is declared abstract, it cannot be instantiated.
  4. When a method is declared abstract, it cannot have definition.
  5. Only abstract classes can have abstract methods. Abstract class does not necessarily require its methods to be all abstract.

  

时间: 2024-08-10 15:09:01

JDK 源码解读之 Number类的相关文章

jdk源码解读之ArrayList

直接上源码: 构造函数:     /**      * Constructs an empty list with an initial capacity of ten.      */     public ArrayList() {     this(10);     } 其实arrayList的本质是一个数据,只不过这个数组的大小可以变化.我们先来看下arraylist的数组是怎么定义的     /**      * Constructs an empty list with the sp

JDK源码解读之Integer(1)

本系列文章使用的JDK版本为jdk1.8.0_131,一些基础的知识储备:原码.反码.补码,移位,建议参考文章:<原码,反码,补码 详解><Java 源码学习系列(三)--Integer> Integer是我们开发过程中最常用的一个类,因此JDK的源码解读就从它开始吧.凡是对Java有点了解的都知道,Integer是int的包装类型,长度为32位.因此我们可以看到如下定义 //可表示的最小值:-2^31,至于为什么是这个数,上面的文章讲的很清楚了 @Native public st

HashTable的故事----Jdk源码解读

HashTable的故事 很早之前,在讲HashMap的时候,我们就说过hash是散列,把...弄碎的意思.hashtable中的hash也是这个意思,而table呢,是指数据表格,也就是说hashtable的本意是指,一份被数据被打散,分散在各处的数据表格. HashTable,作为jdk中,极早提供的容器类(jdk1.0),同时是支持数据并发的类,其在项目中的使用却并不是很广泛.在我所经历的项目中,开发人员往往喜欢使用hashMap然后再通过锁,创造出线程安全的环境.即使是后来推出concu

JDK源码解读之toUnsignedString

我们知道,所有整数都是通过二进制编码的形式存储在内存中的.比如32位的整数,最高位是符号位,0代表正数,1代表负数. 那么怎么才能够将整数的二进制编码形式打印出来呢?Integer类提供了一个公有静态方法toBinaryString能够达到这一目的.我们来看看这段源码: public static String toBinaryString(int i) { return toUnsignedString(i, 1); } /** * Convert the integer to an unsi

HashSet的故事----Jdk源码解读

Hash,我们在说HashMap的时候,已经知道Hash是散列,Map是映射了. 那么Set又是什么呢 ? 先来看看Set的翻译是什么 n. [数] 集合:一套:布景:[机] 装置 这里Set所取的含义是集合.而且是数学概念上的集合.数学概念上的集合有什么特点呢?那就是Set中所有的元素不能重复.所以HashSet的意思就是以散列的形式维持一套不会有重复元素的集合. 接下来我们看看HashSet是怎么被Jdk实现的吧.(其实逻辑非常简单.) 类的声明: hashSet 继承自AbstractSe

JDK源码学习阅读-Integer类中的parseInt方法分析(转)

方法原型: public static int parseInt(String s,int radix): 输入:s表示待转换的字符串:radix表示需要转换成几进制的整数: 输出:返回一个32位整数. 算法流程图: JDK中的代码实现: 1 /** 2 * 字符串转换成整数 3 * @param s 待转换字符串 4 * @param radix 进制 5 * @return 6 */ 7 public static int parseInt(String s,int radix){ 8 //

JDK 源码解读之 Set接口

public interface Set<E> extends Collection<E> { //Set很简单,扩展了Collection Set<E> 和 Collection<E> 都带了<E>,是泛型接口.什么是泛型类,泛型接口呢?Oracle官方文档上是这么说的: A generic class is defined with the following format: class name<T1, T2, ..., Tn>

JDK 源码解读之 ArrayList

public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable 文档中提到:size isEmpty get set iterator listIterator 操作,是( run in constant time), add操作是(run in amortized constant time),而 其他

sklearn中LinearRegression关键源码解读

问题的引入 我们知道,线性回归方程的参数,可以用梯度下降法求解,或者用正规方程求解. 那sklearn.linear_model.LinearRegression中,是不是可以指定求解方式呢?能不能从中获取梯度相关信息呢? 下面是线性回归最简单的用法. from sklearn import linear_model # Create linear regression object regr = linear_model.LinearRegression() # Train the model