Skip to content

java基础知识

zhangjie edited this page Oct 12, 2020 · 4 revisions
  1. java对null进行强转不会报错
  2. 正则表达式
    2.1 建立表达式:Pattern pattern = Pattern.compile("\s")
    (1) 空格:\s
    (2) 数字:[0-9]
    (3) 字母:[a-zA-Z]
    2.2 是否包含:pattern.matcher("xxx").find()
    2.3 是否全部匹配:pattern.matcher("xxx").matches()
    2.4 查看是否包含区分大小写:Pattern padPattern = Pattern.compile(Pattern.quote("pda"),Pattern.CASE_INSENSITIVE)

跳出多层循环

1. 跳出一层循环:
for (int i=0;i<10;i++){
    for(int a=0;a<10;a++){
        break;//跳出a循环,回到i循环
    }
}
2. 跳出两层
labe:for (int i=0;i<10;i++){
    for(int a=0;a<10;a++){
        break labe;//跳出整个循环
    }
}

获取请求路径

Clone this wiki locally