编程语言
首页 > 编程语言> > Java随笔,随时更新

Java随笔,随时更新

作者:互联网

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);

标签:Java,String,ran,s2,Random,result,new,随时,随笔
来源: https://blog.csdn.net/weixin_49158774/article/details/120297607