Object类
this 指针
- this指针指向调优该方法的对象
- 构造器中引用该构造器正在初始化的对象;
- 在方法中调用该方法的对象;
类中的一个方法,访问类中的另一个方法或者变量 - static中不可以使用this对象
Object
- boolean equals(Object obj):判断指定对象与该对象是否相同
- protected void finalize():垃圾回收清理对象;
- class
包装类
public class TestWrapper {
public static void main(String[] args)
{
int i = 100;
Integer iObj = new Integer(i);
int m = iObj.intValue();
}
}
public static void main(String[] args)
{
String iStr = "123";
int i = Integer.parseInt(iStr);
System.out.println(i);
String nStr = String.valueOf(100.234);
System.out.println(nStr);
}
类型 | 包装类 | 位数 |
---|
byte | Byte | 8 |
short | Short | 16 |
int | Integer | 32 |
long | Long | 64 |
float | Float | 32 |
double | Double | 64 |
char | Character | 16 |
boolean | Boolean | 1 |
泛型
List<String> strList=new ArrayList<String>()
List<String> strList=new ArrayList<>()
- 泛型:定义类,接口,方法时使用类型的参数。这个参数在声明变量、创建对象,调用方法适动态的指定
定义泛型接口、类
public interface List<E>{
void add(E x);
Iterator<E> iterator();
}
public interface Iterator<E>
{
E.next();
}
-
List<E>
接口,通过传入不同的参数E,生成多个List接口
类
public class Apple<T>
{
private T info;
......
}
public static void main(String[] args)
{
Apple<String> a1=new Applr<"苹果">
}
泛型派生
punlic class A1 extends Apple<String>
泛型方法
public class G
{
static<T> void formTA(T[] a, Collection<T> c)
...
}
泛型与数组
List<String>[] lsa=new List<String>[10];
string s=las[1].get(0);