Class

  • 获取包信息
    /**
* 获取此对象所在的包
* @revised 9
* @spec JPMS
*/
public Package getPackage() {
// 原始类型和数组无 Package
if (isPrimitive() || isArray()) {
return null;
}
final ClassLoader cl = getClassLoader0();
return cl != null ? cl.definePackage(this)
: BootLoader.definePackage(this);
} /**
* 返回此类的全限定包名
*
* @since 9
* @spec JPMS
* @jls 6.7 Fully Qualified Names
*/
public String getPackageName() {
String pn = this.packageName;
if (pn == null) {
Class<?> c = this;
// 1)获取数组的最底层组件类型
while (c.isArray()) {
c = c.getComponentType();
}
// 2)如果是原始类型
if (c.isPrimitive()) {
pn = "java.lang";
} else {
// 3)获取组件名称
final String cn = c.getName();
// 尝试截取包名称
final int dot = cn.lastIndexOf('.');
pn = dot != -1 ? cn.substring(0, dot).intern() : "";
}
// 缓存包名称
this.packageName = pn;
}
return pn;
}
  • 获取父类
    /**
* 读取此类型的父类 Class
*/
@HotSpotIntrinsicCandidate
public native Class<? super T> getSuperclass();
  • 获取所实现的接口
    /**
* 0)按声明顺序返回此类直接实现的所有接口
* 1)未直接实现任何接口,则返回长度为 0 的数组
* 2)原始类型返回长度为 0 的数组
* 3)数组返回 Cloneable 和 Serializable 组成的数组
*/
public Class<?>[] getInterfaces() {
// defensively copy before handing over to user code
return getInterfaces(true);
} private Class<?>[] getInterfaces(boolean cloneArray) {
final ReflectionData<T> rd = reflectionData();
if (rd == null) {
// no cloning required
return getInterfaces0();
} else {
// 尝试从缓存中读取
Class<?>[] interfaces = rd.interfaces;
if (interfaces == null) {
interfaces = getInterfaces0();
rd.interfaces = interfaces;
}
// defensively copy if requested
return cloneArray ? interfaces.clone() : interfaces;
}
} private native Class<?>[] getInterfaces0();
  • 读取成员类及接口
    /**
* 返回此类及其父类中定义的所有 public 成员类和接口。
* 未定义成员类和接口、原始数据类型、数组都返回长度为 0 的 Class[]。
* @since 1.1
*/
@CallerSensitive
public Class<?>[] getClasses() {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), false);
} return java.security.AccessController.doPrivileged(
(PrivilegedAction<Class<?>[]>) () -> {
final List<Class<?>> list = new ArrayList<>();
Class<?> currentClass = Class.this;
while (currentClass != null) {
// 获取当前类中定义的所有 public 成员类和接口
for (final Class<?> m : currentClass.getDeclaredClasses()) {
if (Modifier.isPublic(m.getModifiers())) {
list.add(m);
}
}
// 递归处理其父类
currentClass = currentClass.getSuperclass();
}
return list.toArray(new Class<?>[0]);
});
} /**
* 读取当前类中定义的所有成员类和接口
* @since 1.1
*/
@CallerSensitive
public Class<?>[] getDeclaredClasses() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), false);
}
return getDeclaredClasses0();
} private native Class<?>[] getDeclaredClasses0();
  • 读取构造函数
    /**
* 读取此类中定义的所有 public 构造函数
* @since 1.1
*/
@CallerSensitive
public Constructor<?>[] getConstructors() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
return copyConstructors(privateGetDeclaredConstructors(true));
} private static ReflectionFactory getReflectionFactory() {
if (reflectionFactory == null) {
reflectionFactory =
java.security.AccessController.doPrivileged
(new ReflectionFactory.GetReflectionFactoryAction());
}
return reflectionFactory;
} // Returns an array of "root" constructors. These Constructor
// objects must NOT be propagated to the outside world, but must
// instead be copied via ReflectionFactory.copyConstructor.
private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
Constructor<T>[] res;
final ReflectionData<T> rd = reflectionData();
if (rd != null) {
// 只读取 public 构造函数还是所有声明的构造函数
res = publicOnly ? rd.publicConstructors : rd.declaredConstructors;
if (res != null) {
return res;
}
}
// No cached value available; request value from VM
// 1)如果是接口
if (isInterface()) {
res = (Constructor<T>[]) new Constructor<?>[0];
} else {
res = getDeclaredConstructors0(publicOnly);
}
if (rd != null) {
if (publicOnly) {
rd.publicConstructors = res;
} else {
rd.declaredConstructors = res;
}
}
return res;
} private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly); /**
* 读取带有指定类型参数列表的 public 构造函数
* @param parameterTypes 参数类型列表
* @since 1.1
*/
@CallerSensitive
public Constructor<T> getConstructor(Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException
{
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
return getReflectionFactory().copyConstructor(
getConstructor0(parameterTypes, Member.PUBLIC));
} /**
* 读取指定带有指定参数类型列表的构造函数
*
* @param parameterTypes 参数类型列表
* @param which
*/
private Constructor<T> getConstructor0(Class<?>[] parameterTypes,
int which) throws NoSuchMethodException
{
final ReflectionFactory fact = getReflectionFactory();
// 读取所有 public 构造函数
final Constructor<T>[] constructors = privateGetDeclaredConstructors(which == Member.PUBLIC);
for (final Constructor<T> constructor : constructors) {
// 数组内容相同
if (arrayContentsEq(parameterTypes,
fact.getExecutableSharedParameterTypes(constructor))) {
return constructor;
}
}
throw new NoSuchMethodException(methodToString("<init>", parameterTypes));
} private static boolean arrayContentsEq(Object[] a1, Object[] a2) {
if (a1 == null) {
return a2 == null || a2.length == 0;
} if (a2 == null) {
return a1.length == 0;
} if (a1.length != a2.length) {
return false;
} for (int i = 0; i < a1.length; i++) {
if (a1[i] != a2[i]) {
return false;
}
} return true;
} /**
* 读取此类中定义的所有构造函数
* @since 1.1
*/
@CallerSensitive
public Constructor<?>[] getDeclaredConstructors() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
}
return copyConstructors(privateGetDeclaredConstructors(false));
} private static <U> Constructor<U>[] copyConstructors(Constructor<U>[] arg) {
final Constructor<U>[] out = arg.clone();
final ReflectionFactory fact = getReflectionFactory();
for (int i = 0; i < out.length; i++) {
out[i] = fact.copyConstructor(out[i]);
}
return out;
} /**
* 读取带有指定类型参数列表的 public 构造函数
*
* @return 指定类型的参数列表
* @since 1.1
*/
@CallerSensitive
public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException
{
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
} return getReflectionFactory().copyConstructor(
getConstructor0(parameterTypes, Member.DECLARED));
}
  • 读取方法
    /**
* 读取此类中定义的所有 public 方法,包括递归从父类和父接口中继承的 public 方法
* @since 1.1
*/
@CallerSensitive
public Method[] getMethods() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
return copyMethods(privateGetPublicMethods());
} // Returns an array of "root" methods. These Method objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyMethod.
private Method[] privateGetPublicMethods() {
Method[] res;
// 1)尝试从缓存中读取
final ReflectionData<T> rd = reflectionData();
if (rd != null) {
res = rd.publicMethods;
if (res != null) {
return res;
}
} // 2)无缓存,读取此类中声明的所有 public 方法
final PublicMethods pms = new PublicMethods();
for (final Method m : privateGetDeclaredMethods(/* publicOnly */ true)) {
pms.merge(m);
} // 3)递归处理父类中的 public 方法
final Class<?> sc = getSuperclass();
if (sc != null) {
for (final Method m : sc.privateGetPublicMethods()) {
pms.merge(m);
}
}
// 4)递归处理父接口
for (final Class<?> intf : getInterfaces(/* cloneArray */ false)) {
for (final Method m : intf.privateGetPublicMethods()) {
// static interface methods are not inherited
if (!Modifier.isStatic(m.getModifiers())) {
pms.merge(m);
}
}
} res = pms.toArray();
// 如果启用了缓存则写入
if (rd != null) {
rd.publicMethods = res;
}
return res;
} private static Method[] copyMethods(Method[] arg) {
final Method[] out = new Method[arg.length];
final ReflectionFactory fact = getReflectionFactory();
for (int i = 0; i < arg.length; i++) {
out[i] = fact.copyMethod(arg[i]);
}
return out;
} /**
* 读取名称为 name,并带有指定参数列表的方法
*
* @param name 方法的名称
* @param parameterTypes 参数类型列表
* @since 1.1
*/
@CallerSensitive
public Method getMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException {
Objects.requireNonNull(name);
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
final Method method = getMethod0(name, parameterTypes);
if (method == null) {
throw new NoSuchMethodException(methodToString(name, parameterTypes));
}
return getReflectionFactory().copyMethod(method);
} // Returns a "root" Method object. This Method object must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyMethod.
private Method getMethod0(String name, Class<?>[] parameterTypes) {
final PublicMethods.MethodList res = getMethodsRecursive(
name,
parameterTypes == null ? EMPTY_CLASS_ARRAY : parameterTypes,
/* includeStatic */ true);
return res == null ? null : res.getMostSpecific();
} // Returns a list of "root" Method objects. These Method objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyMethod.
private PublicMethods.MethodList getMethodsRecursive(String name,
Class<?>[] parameterTypes,
boolean includeStatic) {
// 1)读取所有声明的 public 方法
final Method[] methods = privateGetDeclaredMethods(/* publicOnly */ true);
PublicMethods.MethodList res = PublicMethods.MethodList
.filter(methods, name, parameterTypes, includeStatic);
// 找到匹配方法,则直接返回
if (res != null) {
return res;
} // 递归从父类中查找
final Class<?> sc = getSuperclass();
if (sc != null) {
res = sc.getMethodsRecursive(name, parameterTypes, includeStatic);
} // 递归从接口中查找
for (final Class<?> intf : getInterfaces(/* cloneArray */ false)) {
res = PublicMethods.MethodList.merge(
res, intf.getMethodsRecursive(name, parameterTypes,
/* includeStatic */ false));
} return res;
} /**
* 读取此类中定义的所有方法
* @since 1.1
*/
@CallerSensitive
public Method[] getDeclaredMethods() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
}
return copyMethods(privateGetDeclaredMethods(false));
} // Returns an array of "root" methods. These Method objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyMethod.
private Method[] privateGetDeclaredMethods(boolean publicOnly) {
Method[] res;
// 1)尝试从缓存中读取
final ReflectionData<T> rd = reflectionData();
if (rd != null) {
res = publicOnly ? rd.declaredPublicMethods : rd.declaredMethods;
if (res != null) {
return res;
}
}
// 从 VM 中查找结果
res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly));
// 如果存在缓存,则写入
if (rd != null) {
if (publicOnly) {
rd.declaredPublicMethods = res;
} else {
rd.declaredMethods = res;
}
}
return res;
} /**
* 读取此类中名称为 name 并且具有指定类型参数列表的方法
*
* @param name 方法的名称
* @param parameterTypes 参数类型列表
* @since 1.1
*/
@CallerSensitive
public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException {
Objects.requireNonNull(name);
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
}
final Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes);
if (method == null) {
throw new NoSuchMethodException(methodToString(name, parameterTypes));
}
return getReflectionFactory().copyMethod(method);
} // This method does not copy the returned Method object!
private static Method searchMethods(Method[] methods,
String name,
Class<?>[] parameterTypes)
{
final ReflectionFactory fact = getReflectionFactory();
Method res = null;
for (final Method m : methods) {
// 方法名称一致 && 参数类型列表一致 && 返回值类型兼容
if (m.getName().equals(name)
&& arrayContentsEq(parameterTypes,
fact.getExecutableSharedParameterTypes(m))
&& (res == null
|| res.getReturnType() != m.getReturnType()
&& res.getReturnType().isAssignableFrom(m.getReturnType()))) {
res = m;
}
}
return res;
}
  • 读取属性
    /**
* 返回此类及其递归父类和接口中定义的所有 public 字段
*/
@CallerSensitive
public Field[] getFields() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
return copyFields(privateGetPublicFields());
} private static Field[] copyFields(Field[] arg) {
final Field[] out = new Field[arg.length];
final ReflectionFactory fact = getReflectionFactory();
for (int i = 0; i < arg.length; i++) {
out[i] = fact.copyField(arg[i]);
}
return out;
} // Returns an array of "root" fields. These Field objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyField.
private Field[] privateGetPublicFields() {
Field[] res;
// 尝试从缓存中读取
final ReflectionData<T> rd = reflectionData();
if (rd != null) {
res = rd.publicFields;
if (res != null) {
return res;
}
} final LinkedHashSet<Field> fields = new LinkedHashSet<>(); // 此类中定义的 public 属性
addAll(fields, privateGetDeclaredFields(true)); // 递归的接口中
for (final Class<?> si : getInterfaces()) {
addAll(fields, si.privateGetPublicFields());
} // 递归的父类中
final Class<?> sc = getSuperclass();
if (sc != null) {
addAll(fields, sc.privateGetPublicFields());
} res = fields.toArray(new Field[0]);
if (rd != null) {
rd.publicFields = res;
}
return res;
} // Returns an array of "root" fields. These Field objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyField.
private Field[] privateGetDeclaredFields(boolean publicOnly) {
Field[] res;
// 尝试从缓存中读取
final ReflectionData<T> rd = reflectionData();
if (rd != null) {
res = publicOnly ? rd.declaredPublicFields : rd.declaredFields;
if (res != null) {
return res;
}
}
// 从 JVM 中读取
res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
if (rd != null) {
if (publicOnly) {
rd.declaredPublicFields = res;
} else {
rd.declaredFields = res;
}
}
return res;
} private native Field[] getDeclaredFields0(boolean publicOnly); /**
* 读取指定名称的 public 字段
* @param name 字段名称
* @since 1.1
*/
@CallerSensitive
public Field getField(String name)
throws NoSuchFieldException, SecurityException {
Objects.requireNonNull(name);
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
final Field field = getField0(name);
if (field == null) {
throw new NoSuchFieldException(name);
}
return getReflectionFactory().copyField(field);
} // Returns a "root" Field object. This Field object must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyField.
private Field getField0(String name) {
// Note: the intent is that the search algorithm this routine
// uses be equivalent to the ordering imposed by
// privateGetPublicFields(). It fetches only the declared
// public fields for each class, however, to reduce the number
// of Field objects which have to be created for the common
// case where the field being requested is declared in the
// class which is being queried.
Field res;
// Search declared public fields
if ((res = searchFields(privateGetDeclaredFields(true), name)) != null) {
return res;
}
// Direct superinterfaces, recursively
final Class<?>[] interfaces = getInterfaces(/* cloneArray */ false);
for (final Class<?> c : interfaces) {
if ((res = c.getField0(name)) != null) {
return res;
}
}
// Direct superclass, recursively
if (!isInterface()) {
final Class<?> c = getSuperclass();
if (c != null) {
if ((res = c.getField0(name)) != null) {
return res;
}
}
}
return null;
} // This method does not copy the returned Field object!
private static Field searchFields(Field[] fields, String name) {
for (final Field field : fields) {
// 当前字段的名称和 name 相等
if (field.getName().equals(name)) {
return field;
}
}
return null;
} /**
* 读取此类中直接定义的所有字段
* @since 1.1
*/
@CallerSensitive
public Field[] getDeclaredFields() throws SecurityException {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
}
return copyFields(privateGetDeclaredFields(false));
} private static Field[] copyFields(Field[] arg) {
final Field[] out = new Field[arg.length];
final ReflectionFactory fact = getReflectionFactory();
for (int i = 0; i < arg.length; i++) {
out[i] = fact.copyField(arg[i]);
}
return out;
} /**
* 读取此类中指定名称的字段
*
* @param name 字段名称
* @since 1.1
*/
@CallerSensitive
public Field getDeclaredField(String name)
throws NoSuchFieldException, SecurityException {
Objects.requireNonNull(name);
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
}
final Field field = searchFields(privateGetDeclaredFields(false), name);
if (field == null) {
throw new NoSuchFieldException(name);
}
return getReflectionFactory().copyField(field);
}
  • 读取注解
    /**
* 读取此类上保留策略为 RetentionPolicy.RUNTIME 的所有直接注解,
* 递归读取父类中保留策略为 RetentionPolicy.RUNTIME 并且带有 @Inherited 的所有注解
* 顶层父类的注解优先读取。
* @since 1.5
*/
@Override
public Annotation[] getAnnotations() {
return AnnotationParser.toArray(annotationData().annotations);
} /**
* 读取指定类型的注解
*/
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
Objects.requireNonNull(annotationClass); return (A) annotationData().annotations.get(annotationClass);
} /**
* 读取此类上保留策略为 RetentionPolicy.RUNTIME 的所有直接注解
*/
@Override
public Annotation[] getDeclaredAnnotations() {
return AnnotationParser.toArray(annotationData().declaredAnnotations);
} /**
* 读取此类上保留策略为 RetentionPolicy.RUNTIME 的指定类型的注解
* @since 1.8
*/
@Override
@SuppressWarnings("unchecked")
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
Objects.requireNonNull(annotationClass); return (A) annotationData().declaredAnnotations.get(annotationClass);
} /**
* 获取此类直接的或间接的指定类型的所有注解
* @since 1.8
*/
@Override
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getDirectlyAndIndirectlyPresent(annotationData().declaredAnnotations,
annotationClass);
}

Class 源码解读的更多相关文章

  1. SDWebImage源码解读之SDWebImageDownloaderOperation

    第七篇 前言 本篇文章主要讲解下载操作的相关知识,SDWebImageDownloaderOperation的主要任务是把一张图片从服务器下载到内存中.下载数据并不难,如何对下载这一系列的任务进行设计 ...

  2. SDWebImage源码解读 之 NSData+ImageContentType

    第一篇 前言 从今天开始,我将开启一段源码解读的旅途了.在这里先暂时不透露具体解读的源码到底是哪些?因为也可能随着解读的进行会更改计划.但能够肯定的是,这一系列之中肯定会有Swift版本的代码. 说说 ...

  3. SDWebImage源码解读 之 UIImage+GIF

    第二篇 前言 本篇是和GIF相关的一个UIImage的分类.主要提供了三个方法: + (UIImage *)sd_animatedGIFNamed:(NSString *)name ----- 根据名 ...

  4. SDWebImage源码解读 之 SDWebImageCompat

    第三篇 前言 本篇主要解读SDWebImage的配置文件.正如compat的定义,该配置文件主要是兼容Apple的其他设备.也许我们真实的开发平台只有一个,但考虑各个平台的兼容性,对于框架有着很重要的 ...

  5. SDWebImage源码解读_之SDWebImageDecoder

    第四篇 前言 首先,我们要弄明白一个问题? 为什么要对UIImage进行解码呢?难道不能直接使用吗? 其实不解码也是可以使用的,假如说我们通过imageNamed:来加载image,系统默认会在主线程 ...

  6. SDWebImage源码解读之SDWebImageCache(上)

    第五篇 前言 本篇主要讲解图片缓存类的知识,虽然只涉及了图片方面的缓存的设计,但思想同样适用于别的方面的设计.在架构上来说,缓存算是存储设计的一部分.我们把各种不同的存储内容按照功能进行切割后,图片缓 ...

  7. SDWebImage源码解读之SDWebImageCache(下)

    第六篇 前言 我们在SDWebImageCache(上)中了解了这个缓存类大概的功能是什么?那么接下来就要看看这些功能是如何实现的? 再次强调,不管是图片的缓存还是其他各种不同形式的缓存,在原理上都极 ...

  8. AFNetworking 3.0 源码解读 总结(干货)(下)

    承接上一篇AFNetworking 3.0 源码解读 总结(干货)(上) 21.网络服务类型NSURLRequestNetworkServiceType 示例代码: typedef NS_ENUM(N ...

  9. AFNetworking 3.0 源码解读 总结(干货)(上)

    养成记笔记的习惯,对于一个软件工程师来说,我觉得很重要.记得在知乎上看到过一个问题,说是人类最大的缺点是什么?我个人觉得记忆算是一个缺点.它就像时间一样,会自己消散. 前言 终于写完了 AFNetwo ...

  10. AFNetworking 3.0 源码解读(十一)之 UIButton/UIProgressView/UIWebView + AFNetworking

    AFNetworking的源码解读马上就结束了,这一篇应该算是倒数第二篇,下一篇会是对AFNetworking中的技术点进行总结. 前言 上一篇我们总结了 UIActivityIndicatorVie ...

随机推荐

  1. axios表单提交,delete,get请求(待完善)

    import { mapMutations} from 'vuex' import axios from 'axios' const mixins = { data() { return { } }, ...

  2. 基于VS2017C++的窗口编写

    自从转专业学习计算机后就想写一个简单的有点意义的东西,没有真正接触计算机之前,一直觉得写一个界面什么的很简单.但是现在我都快学了接近一年了才正式自己学习一节界面开发.我想哭-- 我现在学习的是C++窗 ...

  3. javac & java

    # 没有 package, 没有 import 的情况 * 源文件 public class HelloWorld{ public static void main(String[] args){ S ...

  4. Java笔试题及答案

    1.下列不可作为java语言修饰符的是(D) A) a1 B) $1 C) _1 D) 11 答案:java标识符不能以数字开头,包含英文字母,数字,下划线以及$ 2.有一段java 应用程序,它的主 ...

  5. adb常见命令

    adb(Android  Debug  Bridge)主要存放在sdk安装目录下的platform-tools文件夹中,他是一个非常强大的命令行工具.学习adb命令是我在从事兼职测试工作的时候需要掌握 ...

  6. AutoFac控制反转

    一.AutoFac介绍 Autofac是.NET里IOC(Inversion of Control,控制反转)容器的一种,同类的框架还有Spring.NET,Unity,Castle等.可以通过NuG ...

  7. sysbench0.4.12测试query_cache_size和query_cache_type

    建议: query_cache_size和query_cache_type生产环境中关闭. (1)软件包下载地址: https://dev.mysql.com/downloads/benchmarks ...

  8. 题解 最长上升子序列 LIS

    最长上升子序列 LIS Description 给出一个 1 ∼ n (n ≤ 10^5) 的排列 P 求其最长上升子序列长度 Input 第一行一个正整数n,表示序列中整数个数: 第二行是空格隔开的 ...

  9. HDU 6050 - Funny Function | 2017 Multi-University Training Contest 2

    /* HDU 6050 - Funny Function [ 公式推导,矩阵快速幂 ] 题意: F(1,1) = F(1, 2) = 1 F(1,i) = F(1, i-1) + 2 * F(1, i ...

  10. Python—数据类型之字典(Dict)

    其它数据类型转成字典 arr1 = ['jack', 'rose', 'marry'] arr2 = [68, 85, 66] dict1 = dict(zip(arr1, arr2)) print( ...