java package_Java Package getPackages()方法与示例

news/2024/5/18 8:18:15 标签: java, 反射, ajax, spring, jvm

java package

包类的getPackages()方法 (Package Class getPackages() method)

  • getPackages() method is available in java.lang package.

    getPackages()方法java.lang包中可用。

  • getPackages() method is used to return all the packages recently for the callers ClassLoader instance when the caller ClassLoader instance is the bootstrap ClassLoader instance which may be denoted by null in some deployments so the only packages similar loaded by bootstrap loader instance will be returned.

    当调用方ClassLoader实例是bootstrap ClassLoader实例(在某些部署中可能用null表示)时 ,使用getPackages()方法返回调用方ClassLoader实例最近的所有软件包,因此将返回由bootstrap loader实例加载的唯一类似软件包。

  • getPackages() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.

    getPackages()方法是一个静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会收到错误。

  • getPackages() method does not throw an exception at the time of return packages.

    getPackages()方法在返回包时不会引发异常。

Syntax:

句法:

    public static Package[] getPackages();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is Package[], it returns san array of packages for the caller's ClassLoader instance otherwise it returns 0 when no package exists.

此方法的返回类型为Package [] ,它为调用者的ClassLoader实例返回完整的软件包数组,否则,当不存在任何软件包时,它将返回0。

Example:

例:

// Java program to demonstrate the example 
// of Package[] getPackages() of Package method

public class GetPackages {
    public static void main(String[] args) {
        // Get Packages by using getPackages() method
        Package[] pkg = Package.getPackages();

        // Display name of the packages 
        System.out.print("Package Name: ");
        for (int i = 0; i < pkg.length; ++i)
            System.out.print(pkg[i].getName());
    }
}

Output

输出量

Package Name: java.util.zipjava.lang.reflectjava.util.concurrentjdk.internal.org.objectweb.asmsun.security.actionjdk.internal.reflectsun.net.www.protocol.jrtjava.nio.filejava.nio.file.attributesun.security.utiljava.netjava.securityjdk.jfr.internaljava.util.concurrent.atomicjava.util.concurrent.locksjava.nio.file.spijdk.internal.miscjava.lang.refsun.launcherjdk.internal.loadersun.net.wwwjava.utilsun.niosun.invoke.utiljava.lang.invokejdk.internal.refsun.net.www.protocol.jarsun.util.localesun.nio.fssun.reflect.annotationjava.util.streamjava.lang.modulesun.net.utiljdk.internal.utilsun.nio.csjava.util.functionjava.niojava.util.jarjava.iojava.security.certjava.langsun.net.www.protocol.filejava.nio.charset.spijdk.internal.modulejava.lang.annotationjava.nio.charset


翻译自: https://www.includehelp.com/java/package-getpackages-method-with-example.aspx

java package


http://www.niftyadmin.cn/n/1255240.html

相关文章

Matlab一张图上绘制两条曲线-2021-11-05

在MATLAB中将两条曲线画在同一个图上&#xff0c;如果直接采用下面的代码&#xff0c;那么画的第二个图会将第一个图覆盖 plot(x1,y1,‘r’); plot(x2,y2,b’); 正确的做法是在两条语句中间添加hold on; plot(x1,y1,‘r’); hold on;

mogotemplate怎么控制显示字段_led显示屏怎么改字?打开led显示屏控制软件即可

我们会看到各类led显示屏有时是展示使用&#xff0c;有时会临时觉得有的内容需要修改&#xff0c;促销内容会变更&#xff0c;广告语会变更。另外用户并不清楚有同步led显示屏与异步led显示屏。在安装了led拼接屏后&#xff0c;部分用户会担心没有办法对(单色led显示屏)文字进行…

Java Long类hashCode()方法及示例

长类hashCode()方法 (Long class hashCode() method) hashCode() method is available in java.lang package. hashCode()方法在java.lang包中可用。 hashCode() method is used to return hashcode of the Long object. hashCode()方法用于返回Long对象的哈希码。 hashCode() …

python学习之基础入门,安装,字符串,数据转换,三元运算符

python基础    我们要开始学习新的编程语言了,加油~~ python是“世界上最好的语言”&#xff0c;学习它当然是认为它是最好的所以我们才学(人生苦短我学python)&#xff0c;python运用于不同的领域&#xff0c;采集分析&#xff1a;当下大数据时代的大数据分析&#xff1b;…

Java Long类toString()方法及示例

Syntax: 句法&#xff1a; public String toString();public static String toString(long value);public static String toString(long value, int radixs);长类toString()方法 (Long class toString() method) toString() method is available in java.lang package. toStri…

屏幕坏点检测图片_电视屏幕脏了,还在用清水擦拭?这样做会严重破坏电视机!...

原标题&#xff1a;电视屏幕脏了&#xff0c;还在用清水擦拭&#xff1f;这样做会严重破坏电视机&#xff01;电视&#xff0c;是很多家庭必备的家电器&#xff0c;每天最幸福的事情莫过于与家人坐一起开开心心地煲剧。作为使用频率最高的家电器&#xff0c;在日常生活中&#…

C语言多线程编程一

1. Windows下同时打开多个对话框&#xff1a; #include <Windows.h> #include <process.h> //创建线程void runmsg(void *p) {MessageBoxA(0, "hello world", "hello china", 0);}void main() {_beginthread(runmsg, 0, NULL); //启动线…

台式机怎么装蓝牙模块_【硬件篇】第1期:配件选购基础知识(台式机)

去电脑城怕被坑&#xff1b;买品牌机嫌性价比不高&#xff1b;买别人组装好的电脑怕成为整机烈士吧的一员&#xff1b;那么小白如何自己动手拥有属于自己的第一台DIY电脑呢&#xff1f;咱们一步步的来。第一步&#xff1a;确定自己的需求姑且把需求大致分为下面几种&#xff1a…