Java ClassLoader findSystemClass()方法與示例

ClassLoader類findSystemClass()方法 (ClassLoader Class findSystemClass() method)

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

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

  • findSystemClass() method is used to find the class with the given binary name and load the class through the system loader if needed.

    findSystemClass()方法用于查找具有給定二進制名稱的類,并在需要時通過系統加載器加載該類。

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

    findSystemClass()方法是一個非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • findSystemClass() method may throw an exception at the time of finding the class with the given class.

    在使用給定類查找類時, findSystemClass()方法可能會引發異常。

    ClassNotFoundException: This exception may throw when the given class does not exist.

    ClassNotFoundException :如果給定的類不存在,則可能引發此異常。

Syntax:

句法:

    protected Class findSystemClass(String class_name);

Parameter(s):

參數:

  • String class_name – represents the binary name of the class.

    字符串class_name –表示類的二進制名稱。

Return value:

返回值:

The return type of this method is Class, it returns a Class object for the given class name.

該方法的返回類型為Class ,它返回給定類名的Class對象。

Example:

例:

// Java program to demonstrate the example 
// of Class findSystemClass(String class_name)
// method of ClassLoader
class FindSystemClass extends ClassLoader {
void loadedSystemClass() throws ClassNotFoundException {
// It checks whether the given class is loaded
// or not by using the findSystemClass()
Class cl1 = super.findSystemClass("java.lang.String");
// If cl1 not null that means cl1 is loaded
// then don't need to load again
if (cl1 != null)
System.out.println("Class already loaded!!!");
else
System.out.println("Ready to load the given class by using system classloader!!!");
}
}
public class Main {
public static void main(String[] args) throws Exception {
// Creating an instance of FindSystemClass
FindSystemClass sc = new FindSystemClass();
sc.loadedSystemClass();
}
}

Output

輸出量

Class already loaded!!!

翻譯自: https://www.includehelp.com/java/classloader-findsystemclass-method-with-example.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379629.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379629.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379629.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

TFS 鏈接不上

C:\Users\Administrator>net use 會記錄新的網絡連接。 列表是空的。 C:\Users\Administrator>net use \\192.168.1.61\ipc$ wangkun /user:wangkun 命令成功完成。 轉載于:https://www.cnblogs.com/rhythmK/archive/2012/06/04/2534066.html

Linux內核設計與實現---虛擬文件系統

虛擬文件系統1 通用文件系統2 文件系統抽象層3 Unix文件系統4 VFS對象及其數據結構其他VFS對象5 超級快對象超級塊操作6 索引節點對象索引節點操作7 目錄項對象目錄項狀態目錄項緩存目錄項操作8 文件對象9 和文件系統相關的數據結構10 和進程相關的數據結構11 Linux中的文件系統…

Oracle 查詢歷史數據(轉帖)

回復誤刪除數據信息。 1、執行 alter table table_name enable row movement; 2、執行 FlashBack table table_name to timestamp to_timestamp(2012-05-24 14:59:36,yyyy-mm-dd hh24:mi:ss); 查詢歷史操作數據信息。 比較合理的方法是先從閃回區查找出被誤刪的數據&#xff0c…

Java里面的幾種路徑的區別

1,相對路徑 相對路徑就是指由這個文件所在的路徑引起的跟其它文件(或文件夾)的路徑關系。 也就是說: 對于如圖所示:一news.html為例 在WEB15工程下的WebContent下的WEB-INF下的news.html 當我訪問的news.html的時候…

Linux內核設計與實現---塊I/O層

塊I/O層1 解刨一個塊設備2 緩沖區和緩沖區頭3 bio結構體新老方法對比4 請求隊列5 I/O調度程序I/O調度程序的工作Linus電梯最終期限I/O調度程序預測I/O調度程序完全公正的排隊I/O調度程序空操作的I/O調度程序I/O調度程序的選擇系統中能夠 隨機訪問 固定大小數據片的設備被稱為塊…

Java字符類isUpperCase()方法與示例

角色類isUpperCase()方法 (Character class isUpperCase() method) isUpperCase() method is available in java.lang package. isUpperCase()方法在java.lang包中可用。 isUpperCase() method is used to check whether the given char value is uppercase or not. isUpperCas…

javascript:history.go()和History.back()的區別

javascript:history.go()和History.back()的區別收藏 <input typebutton value刷新 οnclick"window.location.reload()"> <input typebutton value前進 οnclick"window.history.go(1)"> <input typebutton value后…

sql查詢行轉列

--SQL 面試題 /* 問題&#xff1a;假設有張學生成績表(tb)如下: 姓名 課程 分數 張三 語文 74 張三 數學 83 張三 物理 93 李四 語文 74 李四 數學 84 李四 物理 94 想變成(得到如下結果)&#xff1a; 姓名 語文 數學 物理 ---- ---- ---- ---- 李四 74 84 94 張三 74 83 93 --…

算法---數

數1 最大公約數2 最小公約數3 進制轉換4 階乘統計階乘尾部0的個數5 字符串加法減法二進制加法6 多數投票問題數組中出現次數多于n/2的元素7 相遇問題改變數組元素使所有元素都相同1 最大公約數 歐幾里得算法&#xff1a;兩個整數的最大公約數等于其中較小的那個數和兩數相除余…

Java ByteArrayOutputStream reset()方法及示例

ByteArrayOutputStream類reset()方法 (ByteArrayOutputStream Class reset() method) reset() method is available in java.io package. reset()方法在java.io包中可用。 reset() method is used to reset this stream (i.e. it removes all currently consumed output in thi…

使用存儲過程修改sql server 2005 用戶密碼

exec sp_password null,新密碼,用戶名轉載于:https://www.cnblogs.com/SXLBlog/archive/2009/07/10/1520590.html

winform TopMost

當設置winform窗體的TopMost屬性為true時&#xff0c;有時會出現不好使的狀況&#xff0c;這可能是因為窗體設置了MdiParent屬性。轉載于:https://www.cnblogs.com/magic-cube/archive/2012/06/10/2544216.html

Linux內核設計與實現---進程地址空間

進程地址空間1 內存描述符分配內存描述符銷毀內存描述符mm_struct與內核線程2 內存區域VMA標志VMA操作內存區域的樹形結構和內存區域的鏈表結構3 操作內存區域find_vma()find_vma_prev()find_vma_intersection()4 mmap()和do_mmap()&#xff1a;創建地址空間mmap&#xff08;&a…

JavaScript中帶有示例的Math.log10()方法

JavaScript | Math.log10()方法 (JavaScript | Math.log10() Method) Math operations in JavaScript are handled using functions of math library in JavaScript. In this tutorial on Math.log10() method, we will learn about the log10() method and its working with e…

JSP技術

一、jsp腳本和注釋 jsp腳本&#xff1a; 1&#xff09;<%java代碼%> ----- 內部的java代碼翻譯到service方法的內部 2&#xff09;<%java變量或表達式> ----- 會被翻譯成service方法內部out.print() 3&#xff09;<%!java代碼%> ---- 會被翻譯成servlet的成…

jQuery.ajax不能實現return值調用問題

我們使用jQuery.ajax函數是不能實現success方法return值的&#xff0c;而有時候我們需要對成功返回的數據進行處理&#xff0c;一般來說&#xff0c;與服務器交互后會返回很多的數據&#xff0c;而有些數據需要進行特別處理&#xff0c;這時需要實現success方法return&#xff…

Linux內核設計與實現---頁高速緩存和頁回寫

頁高速緩存和頁回寫1 頁高速緩存2 基樹3 緩沖區高速緩存4 pdflush后臺例程膝上型電腦模式bdflush和kupdated避免擁塞的方法&#xff1a;使用多線程頁高速緩存&#xff08;cache&#xff09;是Linux內核實現的一種主要磁盤緩存&#xff0c;通過把磁盤中的數據緩存到物理內存中&a…

EL技術

1&#xff0e;EL 表達式概述 EL&#xff08;Express Lanuage&#xff09;表達式可以嵌入在jsp頁面內部&#xff0c;減少jsp腳本的編寫&#xff0c;EL 出現的目的是要替代jsp頁面中腳本的編寫。 2&#xff0e;EL從域中取出數據(EL最重要的作用) jsp腳本&#xff1a;<%requ…

math.trunc_JavaScript中帶有示例的Math.trunc()方法

math.truncJavaScript | Math.trunc()方法 (JavaScript | Math.trunc() Method) Math.trunc() is a function in math library of JavaScript that is used to extract the integer part of the given floating-point number. It removes the decimal and all the digits after…

.NET程序員的書單

zz from sjtu bbs: http://bbs.sjtu.edu.cn/bbscon?boardDotNET&fileM.1126188158.A 發信人: luckySeven(lucky為這位mm默哀), 信區: DotNET 標 題: .NET程序員的書單 發信站: 飲水思源 (2005年09月08日22:02:45 星期四), 轉信 發信人: AtomAndBit (原子與比特), 信區: D…