modifiers在JAVA中_Java Modifier.classModifiers方法代碼示例

news/2024/8/19 9:08:52

import java.lang.reflect.Modifier; //導入方法依賴的package包/類

/**

* Returns a string describing this {@code Class}, including

* information about modifiers and type parameters.

*

* The string is formatted as a list of type modifiers, if any,

* followed by the kind of type (empty string for primitive types

* and {@code class}, {@code enum}, {@code interface}, or

* @{@code interface}, as appropriate), followed

* by the type's name, followed by an angle-bracketed

* comma-separated list of the type's type parameters, if any.

*

* A space is used to separate modifiers from one another and to

* separate any modifiers from the kind of type. The modifiers

* occur in canonical order. If there are no type parameters, the

* type parameter list is elided.

*

*

Note that since information about the runtime representation

* of a type is being generated, modifiers not present on the

* originating source code or illegal on the originating source

* code may be present.

*

* @return a string describing this {@code Class}, including

* information about modifiers and type parameters

*

* @since 1.8

*/

public String toGenericString() {

if (isPrimitive()) {

return toString();

} else {

StringBuilder sb = new StringBuilder();

// Class modifiers are a superset of interface modifiers

int modifiers = getModifiers() & Modifier.classModifiers();

if (modifiers != 0) {

sb.append(Modifier.toString(modifiers));

sb.append(' ');

}

if (isAnnotation()) {

sb.append('@');

}

if (isInterface()) { // Note: all annotation types are interfaces

sb.append("interface");

} else {

if (isEnum())

sb.append("enum");

else

sb.append("class");

}

sb.append(' ');

sb.append(getName());

TypeVariable>[] typeparms = getTypeParameters();

if (typeparms.length > 0) {

boolean first = true;

sb.append('

for(TypeVariable> typeparm: typeparms) {

if (!first)

sb.append(',');

sb.append(typeparm.getTypeName());

first = false;

}

sb.append('>');

}

return sb.toString();

}

}


http://lihuaxi.xjx100.cn/news/236450.html

相关文章

problem-solving-with-algorithms-and-data-structure-usingpython(使用python解决算法和数据结构) -- 基本数据结构(二)...

中缀、前缀和后缀表达式 1. 前缀表达式符号要求所有运算符在它们处理的两个操作数之前。 2. 后缀表达式要求其操作符在相应的操作数之后。 考虑表达式 A B * C , A B C * 是等价的后缀表达式。操作数 A,B 和 C 保持在它们的相对位置,只有操…

codility上的问题 (22)

问题描述: 用1 * 1, 1 * 2的矩形覆盖一个n行m列的矩形,问有多少种方法。 数据范围 : n [1..10^6], m [ 1..7] 要求复杂度: 时间 O(log(n) * 8 ^m)) 空间 O(4^m) 分析:这个题跟之前那个木块砌墙问题一样…… 稍作修…

对象----《你不知道的JS》

最近在拜读《你不知道的js》,而此篇是对于《你不知道的js》中对象部分的笔记整理,希望能有效的梳理,并且深入理解对象 一、语法 对象两种定义形式:声明(文字)形式、构造形式 声明(文字)形式 var…

truetype字体怎么转换成普通字体_win10肿么安装truetype字体

Win 10 、Win 8 系统的默认字体比较模糊,如何改为美观清晰的宋体呢,修改注册表就可以做到,方法如下:方法/步骤Win 10 字体改为宋体方法:新建一个文本文档txt,将如下代码复制进去:Windows Registry Editor V…

python基础===拆分字符串,和拼接字符串

给定某字符,只需要保留其中的有效汉字或者字母,数字之类的。去掉特殊符号或者以某种格式进行拆分的时候,就可以采用re.split的方法。例如 RESTART: Shell >>> s Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.19…

激动人心的AutoCAD .net开发技术

自从了解了vsto和sc(SmartClient)技术后,对以前Win32的二次开发技术,再也没有一点兴趣。对Office VBA, AutoCAD lisp, VBA, PowerBuilder PoserScript, MapInfo MapBasic 的开发,简直室深恶痛绝,希望一切…

java arraylist优点_Java中各种集合的特点总结

1:集合:(1) Collection(单列集合)List(有序,可重复)ArrayList底层数据结构是数组,查询快,增删慢线程不安全,效率高Vector底层数据结构是数组,查询快,增删慢线程安全,效率低LinkedList底层数据结构是链表,查询慢,增删快线程不安全,效率高Set(无序,唯一)HashSet底层数…

Codis 3.2 集群搭建与测试

这里首选分为四个步骤进行一、软件下载codis 3.2.2 https://github.com/CodisLabs/codis/releasescodis-src https://codeload.github.com/CodisLabs/codis/zip/release3.2zeepkeeper 3.5.4 http://ftp.twaren.net/Unix/Web/apache/zookeeper/zookeeper-3.5.4-beta/zookeeper…