UI篇--Android中3种方法实现back键动作

时间:2024-11-24 21:07:37

一、-Xlint:unchecked用法

对如下Test.java编译时

package com.dxz.annotation;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random; public class Test {
public static void main(String[] args) {
ArrayList arr = new Test().getRandom(50);
Iterator it = arr.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
} public ArrayList getRandom(int num) {
ArrayList randomNum = new ArrayList();
Random random = new Random();
int temp = 0;
for (int i = 0; i < num; i++) {
temp = random.nextInt(num);
int nums = temp + 1;
if (randomNum.indexOf(new Integer(nums)) == -1) {
randomNum.add(new Integer(nums));
} else {
i--;
}
}
return randomNum;
}
}

用javac编译

javac com/dxz/annotation/Test.java

结果:

UI篇--Android中3种方法实现back键动作

增加参数-Xlint:unchecked

javac -Xlint:unchecked com/dxz/annotation/Test.java

结果:

UI篇--Android中3种方法实现back键动作

二、-Xlint:deprecation