Java标准版有多少个类?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3112882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 16:33:14  来源:igfitidea点击:

How many classes are there in Java standard edition?

java

提问by Peter Krumins

I am curious how many classes are there in Java standard library. Perhaps someone knows an approximate number?

我很好奇 Java 标准库中有多少个类。也许有人知道一个大概的数字?

采纳答案by Chadwick

By counting entries in the 'all classes' frame of the javadoc API:

通过计算 javadoc API 的“所有类”框架中的条目:

* Javadocs prior to 5.0 are now offline.

* 5.0 之前的 Javadoc 现在离线。

回答by Ben S

I see 3793counting interfaces and abstract classes, as well as private classes.

我看到3793 个计数接口和抽象类,以及私有类。

回答by sepp2k

According to the API documentation 3793 including abstract classes and interfaces.

根据 API 文档 3793 包括抽象类和接口。

回答by emory

I counted 17,338 in Java 6.0. My methodology:

我在 Java 6.0 中数了 17,338。我的方法论:

jar -tf ${JAVA}/jre/lib/rt.jar > rtjar.txt
emacs rtjar.txt

I deleted two lines related to the manifest (and thus not representing a class). I believe that the other lines all refer to classes, but I did not do an exhaustive check. Then I went to the bottom of the file and emacs told me that there 17,338 lines.

我删除了与清单相关的两行(因此不代表一个类)。我相信其他行都是指类,但我没有做详尽的检查。然后我转到文件底部,emacs 告诉我有 17,338 行。

This includes stuff like: java/io/ObjectOutputStream$1.class.

这包括以下内容:java/io/ObjectOutputStream$1.class。

回答by Shrikant Kale

  • Java 1.0.2 : 250 classes
  • Java 1.1 : 500 classes
  • Java 2 (version 1.2-1.4) : 2300 classes
  • Java 5.0 (version 1.5) : 3500 classes
  • Java 1.0.2:250 个类
  • Java 1.1:500 个类
  • Java 2(版本 1.2-1.4):2300 个类
  • Java 5.0(1.5 版):3500 个类

Source : Head First 2nd edition, Chapter 1, p. 4

资料来源:Head First 2nd edition, Chapter 1, p. 4

回答by Do Nhu Vy

I'm also curious about this topic. I found this: enter image description here

我也对这个话题很好奇。我找到了这个: 在此处输入图片说明

(source: Java 8 Pocket Guidebook by Robert Liguori, Patricia Liguori)

(来源:Java 8 袖珍指南,Robert Liguori、Patricia Liguori)

回答by Vivek Vermani

I see 3762 within Java 8 as following

我在 Java 8 中看到 3762 如下

All Classes ( Outer as well as Inner ) , Enums and Interfaces -  3762
All except Inner Classes                                      -  3462
Only Classes ( Outer + Inner + Abstract + Enum )              -  2963
Interfaces                                                    -  799
Enum                                                          -  93  

Moreover , Here is the list of classes / interfaces introduced with each version - http://qr.ae/Q2baW

此外,这是每个版本引入的类/接口列表 - http://qr.ae/Q2baW

回答by Rakesh Yadav

Calculating classes and subclasses is a cumbersome task, but you can know the number of files. 4240 total files in Jdk 8. Click herefor the list of all files.

计算类和子类是一项繁琐的任务,但您可以知道文件的数量。Jdk 8 中总共 4240 个文件。单击此处查看所有文件的列表。

回答by yoborider

For Java SE 9 , according to the API doc 6005 including abstract and interfaces.

对于 Java SE 9,根据 API doc 6005 包括抽象和接口。

For Java SE 10, according to the API doc 6002 including abstract and interfaces.

对于 Java SE 10,根据 API doc 6002 包括抽象和接口。

https://docs.oracle.com/javase/10/docs/api/allclasses-noframe.html

https://docs.oracle.com/javase/10/docs/api/allclasses-noframe.html

Method : view source, and count "<li>" html tag with notepad++.

方法:查看源码,用notepad++统计“<li>”html标签。

For Java SE 11, according to the API doc 4411 including abstract and interfaces.

对于 Java SE 11,根据 API doc 4411,包括抽象和接口。

For Java SE 12, according to the API doc 4433 including abstract and interfaces.

对于 Java SE 12,根据 API doc 4433 包括抽象和接口。

https://docs.oracle.com/en/java/javase/12/docs/api/allclasses-index.html

https://docs.oracle.com/en/java/javase/12/docs/api/allclasses-index.html

Method : view source, and count "colFirst" css class with notepad++

方法:查看源代码,并使用记事本++计算“colFirst”css类