package test;
import java.util.Random;
public class test {
public static void main(String[] args) {
/*1.正则表达式
* String regex = "\\w+@\\w+(\\.\\w{2,3})*\\.\\w{2,3}"; String regex1 =
* "[^0]{1}\\d{10}"; String s ="2223822676@qq.cam"; String s1 = "18535869370";
* if(s.matches(regex)) { System.out.println(s+"这是一个合法的邮箱号码"); }else {
* System.out.println(s+"这是一个非法邮箱"); } if(s1.matches(regex1)) {
* System.out.println(s1+"这是一个合法手机号"); }else {
* System.out.println(s1+"这是一个非法手机号"); }
*/
/*2.字符串生成器
* String str=""; StringBuilder builder= new StringBuilder("");//创建字符串生成器 long
* starTime = System.currentTimeMillis(); for(int i=0;i<100000;i++) {
* builder.append(i); //循环追加字符 } long endTime =System.currentTimeMillis(); long
* time = endTime-starTime; System.out.println("消耗了多少"+time); StringBuilder bu=
* new StringBuilder("hello"); bu.insert(5, "world");
* System.err.println(bu.toString()); StringBuilder bu1= new
* StringBuilder("helloworld"); bu1.delete(3, 4);
* System.out.println(bu1.toString());
*/
/*3.一维数组和二维数组的使用
* String year[] = new String[]{"春","夏","秋","冬"}; for(int i=0; i<4;i++) {
* System.out.println("第"+(i+1)+"季"+year[i]+"天"); }
* int arr[][] = new int[][] {{2},{3,3},{4,4,4}}; for(int i=0;i<arr.length;i++)
* { for(int j=0;j<arr[i].length;j++) {
* System.out.print(arr[i][j]);//不可使用println进行换行 } System.out.println(); }
*/
/*4.冒泡排序法
* int array[] = {32,45,31,54,19,28}; test sorter=new test();//创建一个冒泡类的对象
* sorter.sort(array); } public void sort(int[]array) { for(int
* i=0;i<array.length;i++) { for (int j=0;j<array.length-1;j++) {
* if(array[j]>array[j+1]) { int t=array[j]; array[j]=array[j+1]; array[j+1]=t;
* } } } showArray(array); } public void showArray(int[]array) { for (int
* i=0;i<array.length;i++) { System.out.print(">>"+array[i]); }
* System.out.println();
*/
/*5.对象的比较
* String c1 = new String("abc"); String c2 = new String("abc"); String c3 = c1;
* System.out.println("第一个结果"+(c2==c3));//==比较两个对象的引用地址是否相等
* System.out.println("第二个结果"+(c2.equals(c3)));//equal比较两个对象的引用内容是否相等
*/
/*6.随机数的生成
* System.out.println("任意小写字符"+GetRandomChar('a', 'z'));
System.out.println("任意大写字符"+GetRandomChar('A', 'Z'));
System.out.println("0到9的任意字符"+GetRandomChar('0', '9'));}
public static char GetRandomChar(char char1,char char2) {
return (char)(char1+Math.random()*(char2-char1+1)); }
*/
}
}