`

常用方法

    博客分类:
  • Java
阅读更多
[color=red]String[/color]
    public    String()  
    public    String(String original)  
    public    String(char[] value)  
    public    String(char[] value, int offset, int count)  
    public    String(byte[] bytes)  
    public    String(byte[] bytes, int offset, int length)  
    public    String(byte[] ascii, int hibyte)  
    public    String(byte[] ascii, int hibyte, int offset, int count)  
    public    String(byte[] bytes, String charsetName)  
    public    String(byte[] bytes, int offset, int length, String charsetName)  
    public    String(byte[] bytes, Charset charset)  
    public    String(byte[] bytes, int offset, int length, Charset charset)  
    public    String(int[] codePoints, int offset, int count)  
    public    String(StringBuffer buffer)  
    public    String(StringBuilder builder)  
     
    public char    charAt(int index)  
    public int    codePointAt(int index)  
    public int    codePointBefore(int index)  
    public int    codePointCount(int beginIndex, int endIndex)  
    public int    compareTo(String anotherString)  
    public int    compareToIgnoreCase(String str)  
    public String    concat(String str)  
    public boolean    contains(CharSequence s)  
    public boolean    contentEquals(StringBuffer sb)  
    public boolean    contentEquals(CharSequence cs)  
    public static String    copyValueOf(char[] data, int offset, int count)  
    public static String    copyValueOf(char[] data)  
    public boolean    endsWith(String suffix)  
    public boolean    equals(Object anObject)  
    public boolean    equalsIgnoreCase(String anotherString)  
    public static String    format(String format, Object[] args)  
    public static String    format(Locale l, String format, Object[] args)  
    public int    hashCode()  
    public int    indexOf(int ch)  
    public int    indexOf(int ch, int fromIndex)  
    public int    indexOf(String str)  
    public int    indexOf(String str, int fromIndex)  
    public String    intern()  
    public int    lastIndexOf(int ch)  
    public int    lastIndexOf(int ch, int fromIndex)  
    public int    lastIndexOf(String str)  
    public int    lastIndexOf(String str, int fromIndex)  
    public int    length()  
    public boolean    matches(String regex)  
    public int    offsetByCodePoints(int index, int codePointOffset)  
    public boolean    regionMatches(int toffset, String other, int ooffset, int len)  
    public boolean    regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)  
    public String    replace(char oldChar, char newChar)  
    public String    replace(CharSequence target, CharSequence replacement)  
    public String    replaceAll(String regex, String replacement)  
    public String    replaceFirst(String regex, String replacement)  
    public String[]    split(String regex, int limit)  
    public String[]    split(String regex)  
    public boolean    startsWith(String prefix, int toffset)  
    public boolean    startsWith(String prefix)  
    public CharSequence    subSequence(int beginIndex, int endIndex)  
    public String    substring(int beginIndex)  
    public String    substring(int beginIndex, int endIndex)  
    public char[]    toCharArray()  
    public String    toLowerCase(Locale locale)  
    public String    toLowerCase()  
    public String    toString()  
    public String    toUpperCase(Locale locale)  
    public String    toUpperCase()  
    public String    trim()  
    public static String    valueOf(Object obj)  
    public static String    valueOf(char[] data)  
    public static String    valueOf(char[] data, int offset, int count)  
    public static String    valueOf(boolean b)  
    public static String    valueOf(char c)  
    public static String    valueOf(int i)  
    public static String    valueOf(long l)  
    public static String    valueOf(float f)  
    public static String    valueOf(double d)  
    public void    getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)  
    public byte[]    getBytes(String charsetName)  
    public byte[]    getBytes(Charset charset)  
    public byte[]    getBytes()  
    public void    getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)  
    public boolean    isEmpty() 

[color=red]List[/color]
  boolean 	add(E e)
          向列表的尾部添加指定的元素(可选操作)。
 void 	add(int index, E element)
          在列表的指定位置插入指定元素(可选操作)。
 boolean 	addAll(Collection<? extends E> c)
          添加指定 collection 中的所有元素到此列表的结尾,顺序是指定 collection 的迭代器返回这些元素的顺序(可选操作)。
 boolean 	addAll(int index, Collection<? extends E> c)
          将指定 collection 中的所有元素都插入到列表中的指定位置(可选操作)。
 void 	clear()
          从列表中移除所有元素(可选操作)。
 boolean 	contains(Object o)
          如果列表包含指定的元素,则返回 true。
 boolean 	containsAll(Collection<?> c)
          如果列表包含指定 collection 的所有元素,则返回 true。
 boolean 	equals(Object o)
          比较指定的对象与列表是否相等。
 E 	get(int index)
          返回列表中指定位置的元素。
 int 	hashCode()
          返回列表的哈希码值。
 int 	indexOf(Object o)
          返回此列表中第一次出现的指定元素的索引;如果此列表不包含该元素,则返回 -1。
 boolean 	isEmpty()
          如果列表不包含元素,则返回 true。
 Iterator<E> 	iterator()
          返回按适当顺序在列表的元素上进行迭代的迭代器。
 int 	lastIndexOf(Object o)
          返回此列表中最后出现的指定元素的索引;如果列表不包含此元素,则返回 -1。
 ListIterator<E> 	listIterator()
          返回此列表元素的列表迭代器(按适当顺序)。
 ListIterator<E> 	listIterator(int index)
          返回列表中元素的列表迭代器(按适当顺序),从列表的指定位置开始。
 E 	remove(int index)
          移除列表中指定位置的元素(可选操作)。
 boolean 	remove(Object o)
          从此列表中移除第一次出现的指定元素(如果存在)(可选操作)。
 boolean 	removeAll(Collection<?> c)
          从列表中移除指定 collection 中包含的其所有元素(可选操作)。
 boolean 	retainAll(Collection<?> c)
          仅在列表中保留指定 collection 中所包含的元素(可选操作)。
 E 	set(int index, E element)
          用指定元素替换列表中指定位置的元素(可选操作)。
 int 	size()
          返回列表中的元素数。
 List<E> 	subList(int fromIndex, int toIndex)
          返回列表中指定的 fromIndex(包括 )和 toIndex(不包括)之间的部分视图。
 Object[] 	toArray()
          返回按适当顺序包含列表中的所有元素的数组(从第一个元素到最后一个元素)。
<T> T[]
	toArray(T[] a)
          返回按适当顺序(从第一个元素到最后一个元素)包含列表中所有元素的数组;返回数组的运行时类型是指定数组的运行时类型。

[color=red]Set[/color]
boolean add(E e) 
Adds the specified element to this set if it is not already present (optional operation). 
boolean addAll(Collection<? extends E> c) 
Adds all of the elements in the specified collection to this set if they're not already present (optional operation). 
void clear() 
Removes all of the elements from this set (optional operation). 
boolean contains(Object o) 
Returns true if this set contains the specified element. 
boolean containsAll(Collection<?> c) 
Returns true if this set contains all of the elements of the specified collection. 
boolean equals(Object o) 
Compares the specified object with this set for equality. 
int hashCode() 
Returns the hash code value for this set. 
boolean isEmpty() 
Returns true if this set contains no elements. 
Iterator<E> iterator() 
Returns an iterator over the elements in this set. 
boolean remove(Object o) 
Removes the specified element from this set if it is present (optional operation). 
boolean removeAll(Collection<?> c) 
Removes from this set all of its elements that are contained in the specified collection (optional operation). 
boolean retainAll(Collection<?> c) 
Retains only the elements in this set that are contained in the specified collection (optional operation). 
int size() 
Returns the number of elements in this set (its cardinality). 
Object[] toArray() 
Returns an array containing all of the elements in this set. 
<T> T[] toArray(T[] a) 
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. 


[color=red]Arrays[/color]
		String ss = "afkdhlewrbg";
		CharSequence sd = ss.subSequence(0, ss.length());
		
		char t = sd.charAt(3);
		System.out.println(t);//d
		char[] sf = ss.toCharArray();
		System.out.println(sf[6]);//e
		CharSequence ch = "ddd";
		char[] dd = { 'd', 'd', 'd' };
		char[] dd1 = { 'd', 'd', 'd' };
		System.out.println(dd.toString());//[C@c3c749
     
		List<String>list=Arrays.asList("Larry", "Moe", "Curly");
		Arrays.asList(sf);
		System.out.println(Arrays.binarySearch(sf, 'f'));//1
		System.out.println(Arrays.equals(dd, dd1));//true
		Arrays.sort(sf);
		System.out.println(sf[6]);//h
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics