1,随机数组创建
import java.util.Random; Random ran =new Random(); int a=ran.nextInt(2);
2 ,控制循环时间间隔
while(!result) { Thread.sleep(5 * 100); //设置暂停的时间 5 秒 count++; if (count == 15) { result = true; break; } } catch (InterruptedException e) { e.printStackTrace(); } }
3,判定字符串是否相等
String s1 = new String("abc"); String s2 = new String("abc"); boolean result = s1.equals(s2); System.out.println("The result is :" + result);