标签:char matcher类 console inf dom insert 没有 not adp
1.String类不可以有子类。
2.用户无法输出String对象的引用,输出的是字符序列
3.构造方法:String s = new String("We are students");
4.其他构造方法:String (char a[ ]) 和 String(char a[],int startIndex,int count)
1.String对象可以用“+”进行并置运算,即首尾相接得到一个新的String对象。
1.获取一个String对象的字符序列的长度:public int length()
2.比较当前String对象的字符序列是否与参数s指定的String对象的字符序列相同:public boolean equals(String s)
3.判断当前String对象的字符序列前缀和后缀是否是参数指定的String对象s的字符序列。
public boolean startsWith(String s) //前缀
public boolean endsWith(String s) //后缀
4.按字典序与参数指定的String对象s的字符序列比较大小:public int compareTo(String s)
5.判断当前String对象的字符序列是否包含参数s的字符序列:public boolean contains
6.public int indexOf (String s)和public int lastIndexOf(String s)
7.public String substring(int startpoint) 8.public String trim###字符串与基本数据的相互转化 1.将字符序列转换为int型:x = Integer.parseInt(s); 类似的byte、short、long等等一样。
2.将数值转化为String对象:String str = String.valueOf(int/byte/long/float/double n)
一个对象调用public String toString()方法返回的String对象的字符序列的一般形式为:
创建对象的类的名字@对象的引用的字符串表示
1.字符串与字符数组的方法:getChars//复制到参数c指定的数组中和public char[] toCharArray()
2.字符串与字节数组的方法:
String(byte[],int offset,int length)
public byte[] getBytes()
public byte[] getBytes(String charsetName)
3.字符串的加密算法:P186
1.正则表达式
元字符

限定符

2.字符串的替换
String对象调用public String replaceAll(String regex,String replacement)方法返回一个新的String对象
3.字符序列的分解
使用public String[] split(String regex)方法
分解字符序列,构造方法为:
StringTokenizer(String s)
StringTokenizer(String s, String delim)
方法:1.next()方法用来一次返回被解析的字符序列中的单词
2.如果含有数字可以用nextInt()和nextDouble()来代替next()方法。
1、length():获取实体中存放的字符序列的长度。
2、capacity():获取当前实体的实际容量。
3、StringBuffer append(String s):将String对象s的字符序列追加到当前StringBuffer对象的字符序列中,并返回当前StringBuffer对象的引用。
4、public char charAt(int n)和public void setCharAt(int n,char ch):得到序列位置n上的字符和替换ch指定的字符。
5、StringBuffer insert(int index,String str):将参数str指定的字符序列插入到参数index指定的位置。
6、public StringBuffer reverse():将对象实体中的字符序列翻转。
7、StringBuffer delete(int startIndex,int endIndex):从当前StringBuffer对象的字符序列中删除一个子字符序列,并返回当前对象的引用。
8、StringBuffer replace(int startIndex,int endIndex,String str):将当前StringBuffer对象的字符序列的一个子字符序列用参数str指定的字符序列替换。
1.使用无参数构造方法:Date()
2.使用带参数的构造方法:Date(long time)
3.使用Calendar类的static方法getInstance()可以初始化一个日历对象:Calendar calendar = Calendar.getInstance()
4.calendar对象可以调用方法:
public final void set(int year,int month,int date)
public final void set(int year,int month,int date,int hour,int minute)
public final void set(int year,int month,int date,int hour,int minute,int second)
5.calendar对象调用public long getTimeInMillis()可以返回当前calendar对象中时间的毫秒计时。
format方法:format(格式化模式,日期列表)
format(Locale locale,格式化模式,日期列表);
Math类的常用类方法:
public static long abs(double a)\\ 返回a的绝对值。
public static double max(double a,double b) \\返回a、b的最大值。
public static double min(double a,double b) \\返回a、b的最小值。
BigInteger类的常用类方法:
public BigInteger add(BigInteger val)\\ 返回当前对象与val的和。
public BigInteger subtract(BigInteger val) \\返回当前对象与val的差。
public BigInteger multiply(BigInteger val) \\返回当前对象与val的积。
public Random();
public Random(long seed);###数字格式化 1.可使用String类调用format方法对数字进行格式化。 2.格式化整数 3.格式化浮点数 ###Class类 方法:public static Class forName(String className) throws ClassNotFoundException###Console类 ``` Console cons = System.console(); char[] passwd = cons.readPassword(); ``` ###Pattern类与Matcher类 1.使用正则表达式regex作参数得到一个称为模式的Pattern类的实例pattern:Pattern pattern=Pattern.compile(regex)2.得到可以检索String对象input的Matcher类的实例matcher:Matcher matcher=pattern.matcher(input);`

第一次的实验我抽到了凯撒密码就已经用到了String类,这方便了我这周的学习,也使我几乎没有遇到问题,最近实验越来越多,学习java的时间也越来越少,希望自己可以不忘初心,继续前进。
标签:char matcher类 console inf dom insert 没有 not adp
原文地址:https://www.cnblogs.com/20175309lyh/p/10707244.html