我是靠谱客的博主 兴奋芹菜,这篇文章主要介绍【正则,包装类,包装类等,方法整合】最全,最详细,现在分享给大家,希望可以做个参考。

正则

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
工具: https://regexper.com/ 概念; 使用单个字符串来描述 / 匹配一系列符合某个语法规则的字符串 在java里面来学习正则表达式的目的主要就是使用正则表达式来处理复杂字符串的 查找find 替换 replace 匹配masches 分割split 字符类: [abc] 将字符进行归类,可以出现[]中的其中一个 对abc其中一个进行匹配 [^abc] 对不是abc的字符进行匹配 范围类: [a-z] 表示代表a-z中的一个字符 表示所有的英文字母和数字 [a-zA-Z0-9] 预定义类: d == [0-9] 数字 D == [^0-9] 非数字 空白字符:[ tnx0Bfr] == s [^ tnx0Bfr] == S [a-zA-Z0-9] w [^a-zA-Z0-9] W . 任何字符(与行结束符可能匹配也可能不匹配) 中文; u4e00-u9fa5 分组 如何让jack出现至少3次,而不是k出现3次 错误写法; jack{ 3,} 正确写法; (jack) { 3,} ?: = 忽略分组 每一组能够分组,但是没有编号 ja(ck | love)kitty 或 | 使用步骤 1,通过大量的字符串找规律定义规则 2, 使用这种规则去匹配新的字符串 3,匹配成功做出相应的操作(匹配 查找 替换 分割) 正则表达式由两种基本字符组成 原义字符; ,字符本身就是一个正则表达式,列如 a, b, c, t , n, r .... 元字符 ; * + ? $ ^ ( ) { `} ... 正则表达式在java中的应用总结 1,字符串查找操作 Pattern和Matcher 2,字符串匹配操作 字符串的matches()方法 完全匹配 3,字符串替换操作 字符串的replaceAll()replaceFirst()方法 部分匹配,匹配成功替换 4,字符串分割 split()方法 字符串查找 Pattern和Matcher java是面向对象语音 正则表达式本身也可以理解为一个对象,这个对象java提供了Pattern Matcher他就是匹配器对象 如果需要匹配一个字符串是否满足正则条件需要哪些材料? 1,源字符串 s 2,需要正则表达式对象 Pattern

包装类的引入 (integer转换)

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
为什么需要学习包装类? 1,如何判断一个字符是大写,小写 还是数字字符? c >= 'a' & & c <= 'z' 该判断是与字符相关,应该放在字符类里面 Character char 2,如何计算65的二进制,八进制,十六进制呢? 该计算与整数有关,应该放在整数类里面 Integer Byte Short Long 有了包装类,我们可以访问和数据类型相关的对象更多的方法 基本数据类型是没有什么方法可以调用的 任何数据类型都有一个class属性,他返回的是类文件 什么是包装类? 八大基本数据类型都对应值一个包装类类型 byte short int long float double char boolean Byte Short Integer Long Float Double Character Boolean 掌握Integer 和 Character 其他的一模一样 Integer 是java.lang.Number 包下面的 任何Number类下的子类都可以转换成其他的数据类型,但是可能会出现精度丢失 static int BYTES 用于表示二进制补码二进制形式的 int 值的字节数 static int MAX_VALUE 一个持有最大值一个int可以有 2 31 -1 static int MIN_VALUE 的常量保持的最小值的int可以具有 -2 31 static int SIZE 用于表示二进制补码二进制形式的int值的位数 static 类<Integer> TYPE 类原始类型int 的类实例 Integer(int value) 构造一个新分配的 Integer对象,该对象表示指定的 int 值 Integer (String s) 构造一个新分配 Integer对象,表示 int 由指示值String参数 NumberFormatException 异常名称; 数字格式化异常 产生原因;字符串未满足数字的格式 integer的成员方法 public int Value() 拆箱 将Integer转化为整型 public static int parseInt(string s) 将字符串类型转换为int类型 public static String toString(int i) 将整型转换为字符串 public static Integer valueOf (int i) 将整型转换为Integer类型 public static Integer valueOf ( string s) 将整型转换为Integer类型 实现String和int之间的相互转换 int -- String 方式1 ; int i = 100; String s = i + " "; 方式2; 推荐 String s2 = String.valueof ( i ); 方式3; String s3 = Integer.valueOf( i ) .toString( ); String -- int 方式1; 推荐 String num = " 100 " int i1 = Integer.parseInt( num ); 方式2; int i2 = new Integer(num).intValue( ); 方式3; int i3 = Integer.valueOf( num ).intValue( ); 进制转换 十进制转到其他进制: public static String toString(int i , int radix) 其他进制到十进制: public static int parseInt(int i ,int radix)

Math类概述,方法

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Math.abs (double a) 求绝对值 Math.sqrt ( double a ) 开根号 Math.ceil ( double a ) 向上取整 Math.floor (double a ) 向下取整 Math.max (int a , int b ) 求最大值 Math.min (int a , int b ) 求最小值 Math.pow (double a , double b ) 求a的b次幂 Math.random (random) 生成随机数 Math.round (float a) 四舍五入

character 方法

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Character类是char的包装类。 isUpperCase (char ch) 判断字符是否大写 isLowerCase (char ch) 判断字符是否小写 isDigit (char ch) 判断字符是否是数字 toUpperCase (char ch) 将字符转大写 toLowerCase (char ch) 将字符转小写

BigInteger

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
new BigInteger( “1” ) .add (new BigInteger (“1” )) 加 new BigInteger( “1” ) .subtract (new BigInteger (“1” )) 减 new BigInteger( “1” ) .multiply (new BigInteger (“1” )) 乘 new BigInteger( “1” ) .divide (new BigInteger (“1” )) 除 new BigInteger( “1” ) .reminder (new BigInteger (“1” )) 取余 .deivedAandReminder 取商, 取余 Arrays.toString (new BigInteger( “1” ) .deivedAndReminder (new BigInteger (“1” )) 商 余数

最后

以上就是兴奋芹菜最近收集整理的关于【正则,包装类,包装类等,方法整合】最全,最详细的全部内容,更多相关【正则内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(81)

评论列表共有 0 条评论

立即
投稿
返回
顶部