一、Scanner类常用方法:

public boolean hasNextXxx() 
判断是不是Xxx类型的元素

public Xxx nextXxx()
获取该元素

public int nextInt()
获取一个int类型的值

public String nextLine()
获取一个String类型的值

二、String类的常用方法

判断功能:
boolean equals(Object obj)

 比较字符串内容是否相同,区分大小写

boolean equalsIgnoreCase(String str)
比较字符串的内容是否相同,不区分大小写

boolean contains(String str)
判断大字符串中是否包含小字符串

boolean startWith(String str)
判断字符串是否已str字符开头

boolean endtWith(String str)
判断字符串是否已str字符结尾

boolean isEmpty()
判断字符串是否为空

获取功能:
int length()

获取字符串长度


char charAt(int index)
获取指定索引位置的字符

int indexOf(int ch)
返回指定字符在此字符串第一次出现处的索引

int indexOf(String str)
返回指定字符串在此字符串第一次出现处的索引

int indexOf(int ch,int fromIndex)
返回指定字符在此字符串中从指定位置后第一次出现的索引

int indexOf(String str,int fromIndex)
返回指定字符串在此字符串中从指定位置后第一次出现的索引

String substring(int start)
从指定位置还是截取字符串,默认到结尾

String substring(int start,int end)
从指定位置还是截取字符串,到指定结束位置

转换功能:
byte[] getBytes()

把字符串转换为字节数组

char[] toCharArray()
把字符串转换为字符数组

static String valueOf(char[] chs)
把字符数组转换为字符串

static int valueOf(int i)
把int转换为字符串

/*这个方法什么类型都可以转换成字符串*/

String toLowerCase()
把字符串转成小写

String toUpperCase()
把字符串转成大写

String concat(String str)
把字符串拼接

其他功能:
替换
String replace(char old,char new)
String replace(String old,String new)

去除空格
String trim()

按字典序比较两个字符串
int compareTo(String str)
int compareToIgnoreCase(String str)