常用类方法 排序

Object

object为所有类的顶层父类
hashCode()方法
默认情况下将对象的地址值用哈希算法转换为一个整数值

   int hashCode () 返回该对象的哈希码值

getClass()方法
返回此 Object 的运行时类。

   public final Class getClass()

toString()方法
返回该对象的字符串表示。

   public String toString()

默认情况下的数据对我们来说没有意义,一般建议重写该方法。
一般是将该类的所有的成员变量组成返回即可。

equals()方法
默认比较两个对象的地址值
可以重写比较两个成员变量的值是否相等.

     a.equals(b);

String类

构造方法
public String()空构造
public String(byte[] bytes把字节数组转成字符串
public String(byte[] bytes,int index,int length)
把字节数组的一部分转成字符串(index:表示的是从第几个索引开始, length表示的是长度)
public String(char[] value)把字符数组转成字符串
public String(char[] value,int index,int count):把字符数组的一部分转成字符串
public String(String original):把字符串常量值转成字符串
判断功能
public boolean equals(Object obj)
比较字符串的内容是否相同,区分大小写
public boolean equalsIgnoreCase(String str)
比较字符串的内容是否相同,忽略大小写
public boolean contains(String str)
判断字符串中是否包含传递进来的字符串
public boolean startsWith(String str)
判断字符串是否以传递进来的字符串开头
public boolean endsWith(String str)
判断字符串是否以传递进来的字符串结尾
public boolean isEmpty()
判断字符串的内容是否为空串""。
获取功能
public int length()
获取字符串的长度。
public char charAt(int index)
获取指定索引位置的字符
public int indexOf(int ch)
返回指定字符在此字符串中第一次出现处的索引。
public int indexOf(String str)
返回指定字符串在此字符串中第一次出现处的索引。
public int indexOf(int ch,int fromIndex)
返回指定字符在此字符串中从指定位置后第一次出现处的索引。public int indexOf(String str,int fromIndex
返回指定字符串在此字符串中从指定位置后第一次出现处的索引。public String substring(int start)
从指定位置开始截取字符串,默认到末尾。
public String substring(int start,int end)
从指定位置开始到指定位置结束截取字符串
转换功能
public byte[] getBytes()
把字符串转换为字节数组。
public char[] toCharArray()
把字符串转换为字符数组。
public static String valueOf(char[] chs)
把字符数组转成字符串。
public static String valueOf(int i)
把int类型的数据转成字符串。
注意:String类的valueOf方法可以把任意类型的数据转成字符串。public String toLowerCase()
把字符串转成小写。
public String toUpperCase()
把字符串转成大写。
public String concat(String str)
把字符串拼接。
替换功能
public String replace(char old,char new)
将指定字符进行互换
public String replace(String old,String new)
将指定字符串进行互换

排序

选择排序
选择一个数,和之后的数字进行比较
从0索引开始,依次和后面元素比较,小的往前放,第一次完毕,最小值出现在了最小索引处。
常用类方法 排序
冒泡排序
相邻元素两两比较,大的往后放,第一次完毕,最大值出现在了最大索引处
常用类方法 排序