java.lang
包。用法:
public boolean isAnonymousClass();
参数:
返回值:
这个方法的返回类型是boolean
,它根据以下情况返回一个布尔值,
例:
- // Java program to demonstrate the example
- // of boolean isAnonymousClass () method of Class
-
- public class IsAnonymousClassOfClass {
- public static void main(String[] args) throws Exception {
- String str = new String();
- Class cl1 = str.getClass();
-
- IsAnonymousClassOfClass ac = new IsAnonymousClassOfClass();
- Class cl2 = ac.getClass();
-
- boolean b1 = cl1.isAnonymousClass();
- System.out.println("Is" + " " + cl1.getSimpleName() + " " + "Anonymous Class:" + " " + b1);
-
- boolean b2 = cl2.isAnonymousClass();
- System.out.println("Is" + " " + cl2.getSimpleName() + " " + "Anonymous Class:" + " " + b2);
- }
- }
输出
Is String Anonymous Class: false Is IsAnonymousClassOfClass Anonymous Class: false
好了, 以上是本文所有内容,希望对大家有所帮助,也希望大家对码农之家多多支持,你们的支持是我创作的动力!祝大家生活愉快!