异常Throwable类
Error:错误,这类错误不需要程序员管理
Exception:异常
throw,制造异常;throws,抛出异常;try…catch,捕获异常
String类
1.char charAt(int index),指定返回指定的索引处的值
2.int codePointAt(int index),返回指定索引处字符对应的Unicode代码点
3.int compareTo(String anotherString)按字典顺序比较两对字符串如果相等则输出0,若this比参数的对象大返回整数,否则返回负数的差值,区分大小写
4.compareTolgnoreCase(String str),按字典顺序比较两个字符串,不考虑大小写
5.String concat(String str),将指定字符串链接到此字符串结尾
6.boolean contains(CharSequence s),当且仅当此字符串包含指定的char值序列 式,返回true
7.static String copy ValueOf(char[] data),返回指定 数组中表示该字符序列的String
8.boolean endsWith(String suffix),测试此字符是否以指定的后缀结束
9.boolean startsWith(String prefix),测试此字符是否以指定的前缀开始
10.byte[] getBytes() 字符串转字节数组
11.int indexOf(String str),返回 指定字符串在此字符串中第一次出现的索引
12.String replace(char oldChar,char newChar),返回一个新字符串,它是通过用 newChar 替换此字符串中出现的所有 oldChar 得到的。
13.String[] split(String regex),根据给定正则表达式的匹配拆分此字符
14.String substring(int beginlndex),返回一个字符串,他是此字符串的一个子字符串
15.String substring(int beginlndex,int endlndex)返回一个字符串,他是此字符串的一个子字符串,结束位置索引获取不到
16.char[] toCharArray(),将此字符串转换成一个新的字符数组
17.String toLowerCase(),方法用于将大写字符转换为小写
18.String toUpperCase(),方法用于将大写字符转换为大写
19.String trim() 返回字符串的副本,忽略前导空白和尾部空白
20.static String valueOf(int i),返回int参数的字符串表示形式
String str="shsxtverygood";
String str2="Shsxtverygood";
String str3=" name=李四";
System.out.println("charAt():"+str.charAt(3)); //x ->1
System.out.println("codePointAt():"+str.codePointAt(3)); //120 ->2
System.out.println("compareTo():"+str2.compareTo(str)); //-32 ->3
System.out.println("compareToIgnoreCase():"+str.compareToIgnoreCase(str2)); //0 ->4
System.out.println("concat():"+str.concat(str2)); //shsxtverygoodShsxtverygood ->5
System.out.println("contains():"+str.contains("sxt")); //true ->6
System.out.println("copyValueOf():"+String.copyValueOf(new char[]{'s','x','t'})); //sxt ->7
System.out.println("copyValueOf():"+String.copyValueOf(new char[]{'s','x','t'},1,2)); //xt ->7
System.out.println("endsWith():"+str.endsWith("good")); //true ->8
System.out.println("startsWith():"+str.startsWith("shsxt")); //true ->9
System.out.println("getBytes():"+str.getBytes("utf-8")); //true ->10
System.out.println("indexOf():"+str.indexOf("o")); //10 ->11
System.out.println("lastIndexOf():"+str.lastIndexOf("o")); //11 ->11
System.out.println("replace():"+str.replace("oo","OO")); //11 ->12
System.out.println(str); //11 ->
String[] arr=str3.split("="); //->13
System.out.println(Arrays.toString(arr));
System.out.println(arr[1]);
System.out.println("substring():"+str.substring(5)); //11 ->14
System.out.println("substring():"+str.substring(5,8)); //11 ->15
System.out.println(str.toCharArray()); //shsxtverygood ->16
System.out.println("toLowerCase"+str.toLowerCase()); //-> 17
System.out.println(str3.toUpperCase()); //shsxtverygood ->18
System.out.println("trim():"+str3.trim()); //shsxtverygood ->19
System.out.println("valueOf():"+String.valueOf(123).length());//-> 20
基本类型,包装类
基本数据类型的包装类 包装类
-
byte — Byte
-
short — Short
-
int — Integer
-
long — Long
-
char — Character
-
float — Float
-
double — Double
-
boolean — Boolean
-
自动装箱:基本数据类型–>包装类型
-
自动拆箱:包装类型–>基本数据类型
Date 日期类
SimpleDateFormat 日期格式类|转换类|转换器
-
指定格式
-
y->年
-
M->月
-
d->日
-
H->24小时
-
h->12小时
-
m->分
-
s->秒
-
S->毫秒
-
format(Date)–>日期对象转为字符串,可以按照指定格式,可以使用转换器的默认格式
-
parse(String) -->把字符串转为日期对象,按照指定格式转换
enume,枚举
列举所有情况,可以枚举类
- 1.枚举类也是类,类中的字段|属性都是该类的一个实例,默认相当于使用public static final修饰
- 2.枚举类隐式的继承了java.lang.Enum