您的位置:首页 > 职场人生

java基础面试题

2013-07-23 00:00 211 查看
摘要: java基础 方法 及 返回值

public class StringTest {

public static void main(String[] args){

System.out.println("abc".compareTo("kkk"));//
返回值 是 内容的真实差值 而不是 0 1 -1

String reg = "[0-9]{3}"; //
要与 js的正则区别开来

boolean k = "123".matches(reg); //方法名是
matches

System.out.println(k);

System.out.println(Pattern.matches(reg, "131"));//或是直接调用

Pattern p = Pattern.compile("a*b"); //compile

Matcher m = p.matcher("aaaaab"); //matcher

boolean b = m.matches(); //matches()

System.out.println(b);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息