整型數組:
//靜態初始化
int[] intArr = new int[]{1,2,3,4,5,6};
//簡化版
int[] intArr = {1,2,3,4,5,6};
//動態初始化
int[] intArr = new int[6];
//初始化二維數組
int[][] intMatrix = {{1,2},{3,4},{5,6}};
int[][] intMatrix = new int[3][2];
//獲取數組長度
int rowLength = intMatrix.length;//行數
int colLength = intMatrix[0].length;//第0行列數
字符串
//初始化
String str = "hello,world";
//字符串長度
System.out.println(str.length());
//遍歷字符串
for(int i=0;i<str.length();i++){
char ch = str.charAt(i);
}
//字符轉ASCII碼
char a = 'a'
int a_ASCII = (int) a;
//截取子字符串
String Str = “hello,world”;
String subStr = str.substring(2,4)//out:"ll"
常用ASCII碼
數字0-9 :48~57.
26個大寫字母:65~90.
26個小寫字母:97~122.