Common Java classes and their common methods

Source: Internet
Author: User
Tags bitset comparable int size

1, ArrayList

Java.util.arraylist<e>add (e E)              //Insert trailing Add (int index, E Element) remove (int index) remove (Object o) Get (int Index) indexOf () lastIndexOf () IsEmpty () size () iterator () Listiterator () Java.util interface Iterator<e>hasnext () next () Remove ()


2, Arrays and Collections tool class

System.arraycopy (object src, int srcpos, object dest, int destpos, int length) java.util.Arraysstatic int BinarySearch () If not found then return (-(insertion point)-1), not necessarily-1. Static Boolean Equals ()//judgment array equals static void Fill () static void sort () static <T> void sort (t[] A, Comparat or<? Super t> C) java.util.Collectionsstatic <T> int BinarySearch (list<? extends Comparable<? Super t>> L ist, T key) Max (collection<? extends t> Coll) min (collection<? extends t> coll) static void reverse (list<?& Gt List) sort (list<t> list) static <T> void sort (list<t> list, comparator<? super t> C) static <t& Gt Comparator<t> Reverseorder ()//important java.util. Interface Comparator<t>public interface comparator<t> {int CO Mpare (t O1, T O2); Boolean equals (Object obj);}  Java.lang. Interface Comparable<t>public interface comparable<t> {int compareTo (T o);} Java.util.BitSetBitSet () BitSet (int nbits)//By default, all bits in the set have an initial value of Falsevoid CleaR (int bitindex)//sets the bit at the index specified to False. void clear ()//sets all bits in this BitSet to false. void Flip (int index)//invert means position Boolean get (int index) BitSet get (int from, int to) Boolean isEmpty ()//when no TR UE bit, returns Trueint length ()//Maximum index +1 (highest 1 index, not 9 in Bitset (10)) void set (int bitindex)//sets the bit at the specified index to true. void set (int fromIndex, int toindex, Boolean value)//sets the specified FromIndex (including) to the specified Toindex (not included) in the range of bits to the specified value.  String toString ()//Returns a string representation, Bs.set (4); Bs.set (6), followed by "{4,6}"


3, HashMap

Java.util.hashmap<k, V>boolean containskey (Object key), Boolean Containsvalue (object value) set<map.entry< K,v>> EntrySet () v Get (Object key) Boolean isEmpty () set<k> KeySet () v Put (K key, v value)       //Add key value pair, if key is present, Replace Valuev Remove (Object key) int size () java.util. Interface map.entry<k,v>         //is the static internal interface of the MAP interface public static interface Map.entry<k,v>k GetKey () v GetValue () v SetValue (v value)


4, HashSet

Java.util.hashset<e>boolean Add (E E) boolean remove (Object O), Boolean contains (Object O), Boolean isEmpty () int size ( ) iterator<e> Iterator ()


5, LinkedList

Java.util.linkedlist<e>public class Linkedlist<e> extends Abstractsequentiallist<e>implements List<e>, Deque<e>, cloneable, Serializableboolean Add (e E)                    //Add to end void AddFirst (e e) void AddLast (e e) E Removefirst () e removelast () e element ()                   //Acquire but not remove header e get (int index) e getfirst () e getlast () int indexOf (Object o)                 / /not included then returns -1int LastIndexOf (object o)             //Not included then returns -1boolean contains (object o) int size () iterator<e> Iterator () E Set (int index, E Element)


6. Object

Finalize () Clone () 3 Wait () notify () Notifyall () getclass () equals () Hashcode () toString () Altogether 11 methods!!


7. Pattern and Matcher

Java.util.regex.Patternstatic Pattern Compile (string regex) Static Boolean matches (string regex, charsequence input) Matcher Matcher (charsequence input) Java.util.regex.Matcherwhile (M.find ()) {String str1 = M.group (); String str2 = M.group (2); Boolean B1 = M.lookingat ();        Head matching Boolean b2 = M.matches ();} int start ()//    previous Match initial index int end ()//offset of one character after last match character Matcher Reset ()  //Reset Match string ReplaceAll (string Replacement)     //Replace the pattern with each subsequence of the input sequence that matches the given replacement string. String Replacefirst (String replacement)

8, String

Static comparator<string> Case_insensitive_order;charat () compareTo () Comparetoignorecase () contains () StartsWith () EndsWith () equals ()             //Judgment string equality cannot be used ==indexof () lastIndexOf () isEmpty () length () matches (string regex) Replace () ReplaceAll (string regex, string replacement) Replacefirst (string regex, string replacement) string[] Split ( String regex) substring (int begin)                  //Note method notation substring (int begin, int end)          //Note method notation, end does not include toLowerCase () toUpperCase () trim ()                      //Ignore whitespace before and after


9, StringBuilder

StringBuilder () StringBuilder (String str) append ()   the difference between capacity () and length ()!! Suggest Forget it!! CharAt () Delete (int start, int end)    //Does not contain Endindexof () lastIndexOf () insert (int offset, charsequence s) length () Reverse () substring (int begin)                  //Note method notation substring (int begin, int end)          //Note method notation, end does not include String toString () There is no Equals () method!!!!!!!! There is no Equals () method!!!!!!!! There is no Equals () method!!!!!!!!


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Common Java classes and their common methods

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.