Java類類的getDeclaringClass()方法和示例

類的類getDeclaringClass()方法 (Class class getDeclaringClass() method)

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

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

  • getDeclaringClass() method is used to return the declared Class object denoting the Class in which it is declared when this class or interface denoted by this Class is a part or member of other class.

    當此類表示的該類或接口是其他類的一部分或成員時,使用getDeclaringClass()方法返回聲明的Class對象,該對象表示在其中聲明該Class的Class。

  • getDeclaringClass() 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.

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

  • getDeclaringClass() method does not throw an exception at the time of returning Class object.

    返回Class對象時, getDeclaringClass()方法不會引發異常。

Syntax:

句法:

    public Class getDeclaringClass ();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of this method is Class, it returns an object of declared class from this Class.

此方法的返回類型為Class ,它從該Class返回一個聲明的class的對象。

Note:

注意:

  • When the class or interface is not part or member of other class, null is returned.

    當該類或接口不是其他類的一部分或成員時,將返回null

  • When this class reflects primitive or void type or an array class, null is returned.

    當此類反映原始類型或void類型或數組類時,將返回null

Example:

例:

// Java program to demonstrate the example 
// of Class getDeclaringClass() method of Class 
import java.lang.reflect.*;
public class GetDeclaringClassOfClass {
public static void main(String[] args) {
// It returns the Class object with 
// the given class name
Class cl = Integer.class;
// It returns an array of Methods 
// that denotes the private, protected, public and default 
// Methods of the class Integer
Method[] methods = cl.getMethods();
// Traverse Integer class
for (int i = 0; i < methods.length; ++i) {
Class declare_classes = methods[i].getDeclaringClass();
System.out.print(" Declaring Methods Class: ");
System.out.println(declare_classes.toString());
}
}
}

Output

輸出量

 Declaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.IntegerDeclaring Methods Class: class java.lang.ObjectDeclaring Methods Class: class java.lang.ObjectDeclaring Methods Class: class java.lang.ObjectDeclaring Methods Class: class java.lang.ObjectDeclaring Methods Class: class java.lang.ObjectDeclaring Methods Class: class java.lang.Object

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

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

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

相關文章

樂高泰坦機器人視頻解說_“安防”機器人將亮相服貿會

可巡視園區、自動避障、自動充電&#xff0c;實現24小時巡邏&#xff0c;與后臺鏈接實時視頻監控&#xff0c;異常檢測……17日下午&#xff0c;北青-北京頭條記者在特斯聯科技集團有限公司的展廳中看到&#xff0c;一款“身懷絕技”的“安防”機器人備受關注。這款機器人也將在…

ios上傳文件云服務器上,ios文件上傳服務器

ios文件上傳服務器 內容精選換一換在當前的遷移流程中&#xff0c;可能會存在遷移后ECS控制臺鏡像名稱與實際操作系統不一致的現象。在當前機制下&#xff0c;該現象屬于正常現象。該處顯示的是下發ECS時使用的鏡像名稱&#xff0c;而不是操作系統名稱。如果設置目的端時使用的…

這是一個UIImage集合類,可以很方便的對圖片的染料(著色),增加亮度(閃電)和降低亮度(黑)和其他擴展的功能模塊。...

2019獨角獸企業重金招聘Python工程師標準>>> 這是一個UIImage集合類&#xff0c;可以很方便的對圖片的染料&#xff08;著色&#xff09;&#xff0c;增加亮度&#xff08;閃電&#xff09;和降低亮度&#xff08;黑&#xff09;和其他擴展的功能模塊。 在swift下實…

python爬取酷狗音樂top500_python獲取酷狗音樂top500的下載地址 MP3格式

下面先給大家介紹下python獲取酷狗音樂top500的下載地址 MP3格式&#xff0c;具體代碼如下所示&#xff1a;# -*- coding: utf-8 -*-# Time : 2018/4/16# File : kugou_top500.py# Software: PyCharm# pyVer : python 2.7import requests,jsonheaders{UserAgent : Mozilla/5.0 …

微商相冊一直顯示服務器偷懶,【小程序】微商個人相冊多端小程序源碼以及安裝...

程序介紹學習node.js順便接的400元單子&#xff0c;前后端都是自己寫&#xff0c;相比自己以前寫的&#xff0c;這次相對來說比較規范&#xff0c;用于個人相冊展示&#xff0c;適合微商&#xff0c;有客服聯系&#xff0c;無需后臺管理系統&#xff0c;小程序上直接進行管理&a…

stl優先隊列定義可以嗎_C ++ STL | 用戶定義的優先級隊列比較器

stl優先隊列定義>可以嗎In this article, we are going to see how to write your comparator function for priority queue in C STL using the lambda function. This is going to help you certainly to use priority queue more widely when you may have skipped think…

python編程求三角形面積公式_python編程 輸入三角形的三條邊,計算三角形的面積\...

展開全部# -*- coding: UTF-8 -*-# Filename : test.py# author by : www.runoob.coma float(input(輸入三角62616964757a686964616fe59b9ee7ad9431333433633338形第一邊長: ))b float(input(輸入三角形第二邊長: ))c float(input(輸入三角形第三邊長: ))# 計算半周長s (a …

ipfs分布式存儲網絡服務器系統,IPFS分布式存儲是什么意思 分布式云存儲服務器詳解...

一直以來&#xff0c;數據的安全性&#xff0c;存儲的隱私性都是用戶很重視的方面。基于此&#xff0c;再加上現在媒體對于分布式存儲的瘋狂報道&#xff0c;分布式存儲一詞再度涌入了大家的視野之中&#xff0c;接下來IPFS新說就為大家詳解一下有關IPFS分布式存儲的知識。VIPF…

c# 插入樹形數據#_C#數據類型能力問題 套裝1

c# 插入樹形數據#This section contains aptitude questions and answers on C# data types (set 1). 本節包含有關C&#xff03;數據類型(集合1)的能力問題和答案。 1) "int" is an alias of _________. System.Int16System.Int32System.Int64System.Byte Answer &…

python django框架怎么爬蟲步驟_[Python爬蟲]---Django視頻教程

[↓↓↓資源簡介↓↓↓]Django是一個開放源代碼的Web應用框架&#xff0c;由Python寫成。采用了MVC的框架模式&#xff0c;即模型M&#xff0c;視圖V和控制器C。它最初是被開發來用于管理勞倫斯出版集團旗下的一些以新聞內容為主的網站的&#xff0c;即是CMS(內容管理系統)軟件…

小程序 || 語句_C ++開關語句| 查找輸出程序| 套裝1

小程序 || 語句Program 1: 程序1&#xff1a; #include <iostream>using namespace std;int main(){switch (printf("Hello World")) {case 0x09:cout << " India";break;case 0x0A:cout << " Australia";break;case 0x0B:co…

python爬蟲與django_請問django和爬蟲程序如何整合?

Django 模型是與數據庫相關的&#xff0c;與數據庫相關的代碼一般寫在 models.py 中&#xff0c;Django 支持 sqlite3, MySQL, PostgreSQL等數據庫&#xff0c;只需要在settings.py中配置即可&#xff0c;不用更改models.py中的代碼&#xff0c;豐富的API極大的方便了使用。本節…

Spark的枚舉類型實例!scala的枚舉。

Spark的枚舉類型實例&#xff01;scala的枚舉。Enumeration定義&#xff1a;[deploy] SparkSubmitAction { Value Value }Enumeration使用&#xff1a;appArgs. {SparkSubmitAction.> (appArgs)SparkSubmitAction.> (appArgs)SparkSubmitAction.> (appArgs) }轉載于:…

c ++查找字符串_C ++類和對象| 查找輸出程序| 套裝5

c 查找字符串Program 1: 程序1&#xff1a; #include <iostream>using namespace std;class Sample {int X;int* PTR &X;public:void set(int x) const;void print();};void Sample::set(int x) const{*PTR x;}void Sample::print(){cout << *PTR - EOF <…

mysql8和5.7區別_mysql8.0與mysql5.7安全加密小差別

今天升級到了mysql8.0 做主從同步遇到下面問題2020-07-21T14:09:52.626718Z 13 [ERROR] [MY-010584] [Repl] Slave I/O for channel : error connecting to master slave_replication172.20.0.2:3306 - retry-time: 60 retries: 1 message: Authentication plugin caching_sha2…

c ++查找字符串_C ++類和對象| 查找輸出程序| 套裝3

c 查找字符串Program 1: 程序1&#xff1a; #include <iostream>using namespace std;class Sample {int X;public:void set(int x){X x;}void print(){cout << X << " ";}} A, B;int main(){A.set(10);B.set(20);A.print();B.print();return 0;…

時間輪

老早之前就聽說時間輪算法特別高效&#xff0c;Linux內核都用的它&#xff0c;這兩天抽空實現了遍……嗯&#xff0c;被差一bug搞死(~&#xffe3;▽&#xffe3;~) 啊哈 網上扣來的圖&#xff0c;原理好懂&#xff1a;輪子里的每格代表一小段時間&#xff08;精度&#xff09;…

qc35 說明書_使用Bose QC35 2年的心得 | 遲而不遲的深度體驗 | 文附佩戴效果照片...

小編注&#xff1a;此篇文章來自即可瓜分10萬金幣&#xff0c;周邊好禮達標就有&#xff0c;邀新任務獎勵無上限&#xff0c;點擊查看活動詳情創作立場聲明&#xff1a;本文所測商品為自費購入&#xff0c;我會在文中點明。堅持來自內心的主觀評測是起碼的底線&#xff0c;不會…

threadgroup_Java ThreadGroup類的checkAccess()方法和示例

threadgroupThreadGroup類的checkAccess()方法 (ThreadGroup class checkAccess() method) checkAccess() method is available in java.lang package. checkAccess()方法在java.lang包中可用。 checkAccess() method is used to check whether the currently running thread h…

qt tab彈出特效_Nuke Studio 12(影視特效合成軟件)中文版分享

Nuke 12是一款功能強大&#xff0c;世界知名的影視后期特效合成軟件。NUKE是一個獲得學院獎(Academy Award)的數碼合成軟件。已經經過10年的歷練&#xff0c;為藝術家們提供了創造具有高質素的相片效果的圖像的方法。NUKE無需專門的硬件平臺&#xff0c;但卻能為藝術家提供組合…