collection的一些基础题学习
This commit is contained in:
parent
28da35a5f8
commit
e1f2920261
|
|
@ -0,0 +1,35 @@
|
|||
package com.markilue.java_learning.collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: java_learning
|
||||
* @BelongsPackage: com.markilue.java_learning.collection
|
||||
* @Author: dingjiawen
|
||||
* @CreateTime: 2022-09-23 16:38
|
||||
* @Description:
|
||||
* TODO 面试题中的一些集合类题
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class Problem {
|
||||
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
//注意这里可以不指定泛型不报错,但是不能加上<>了。不然会报错
|
||||
List list1=new ArrayList();
|
||||
list1.add(0);
|
||||
List list2=list1;
|
||||
System.out.println(list1.get(0) instanceof Integer); //true
|
||||
System.out.println(list2.get(0) instanceof Integer); //true
|
||||
System.out.println(list1.get(0).getClass()); //class java.lang.Integer
|
||||
System.out.println(list1.get(0).getClass().getName()); //java.lang.Integer
|
||||
Class<?> aClass = list1.get(0).getClass();
|
||||
String name = list1.get(0).getClass().getName();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue