/*1:stringbuffer (Master) (1) With string concatenation, time consuming and also consumes memory, and this splicing operation is more common, in order to solve this problem, Java provides a string buffer class. StringBuffer for our use. (2) StringBuffer construction Method A:stringbuffer () b:stringbuffer (int size) c:stringbuffer (String str) (3) Stringbu Common functions of Ffer (Explanation of the Declaration and method of self-completion method) A: Add function B: Remove function C: Replace function D: Invert function E: intercept function (note this return value) (4) Stringbuff Er's exercise (do it again) a:string and StringBuffer convert String--StringBuffer construction method StringBuffer --String ToString () method B: Concatenation of strings C: Reverse the string D: Determine if a string is symmetrical (5) Small details of the interview question: StringBuffer: Synchronous, data security, low efficiency. StringBuilder: Out of sync, data insecure, high efficiency. What is the difference between the A:string,stringbuffer,stringbuilder B:stringbuffer and the array? (6) Note the problem: string as the formal parameter, StringBuffer as the formal parameter. 2: Array advanced and Arrays (master) (1) Sort A: Bubble sort adjacent element 22 comparison, large back, the first time is over, the maximum value appears at the maximum index. In the same vein, other elements can be lined up. public static void Bubblesort (int[] arr) {for (intx=0; x<arr.length-1; X + +) {for (int y=0; y<arr.length-1-x; y++) {if (Arr[y] > arr[y+1]) { int temp = Arr[y]; Arr[y] = arr[y+1]; ARR[Y+1] = temp; }}}} B: Select sort 0 to index the element, and index 1 after the elements are compared, the first time is complete, the minimum value Appeared in the 0 index. In the same vein, other elements can be lined up. public static void Selectsort (int[] arr) {for (int x=0; x<arr.length-1; x + +) {for (in T y=x+1; y<arr.length; y++) {if (Arr[y] < arr[x]) {int temp = arr[x]; ARR[X] = Arr[y]; Arr[y] = temp; }}}} (2) Find a: Basic find out about unordered array conditions PU Blic static int getindex (int[] arr,int value) { int index =-1; for (int x=0; x<arr.length; x + +) {if (arr[x] = = value) {index = x; Break }} return index; } B: Binary lookup (binary lookup) for array ordering (never sort first, find) public static int BinarySearch (int[] Arr,in T value) {int min = 0; int max = arr.length-1; int mid = (Min+max)/2; while (Arr[mid]! = value) {if (Arr[mid] > value) {max = mid-1; }else if (Arr[mid] < value) {min = mid + 1; } if (min > Max) {return-1; } mid = (Min+max)/2; } return mid; } (3) Arrays Tool Class A: is a tool class that operates on an array. Includes functions such as sorting and finding. B: The method to be mastered (self-completion method) convert the array to a string: sort: Binary search: (4) Source code Parsing of Arrays tool Class (5) sort the characters in the string for example: "EDACBGF" Get Results "ABCDEFG" 3:integer (Master) (1) In order to have more operations on the basic types of data, Java provides the corresponding wrapper class type for each base type BYTE byte short short int Integer long long float F Loat Double Double Char Character Boolean boolean (2) integer constructor method a:in Teger i = new Integer (100); B:integer i = new Integer ("100"); Note: Here the string must be composed of numeric characters (3) of the mutual conversion of string and int a:string-int integer.parseint ("100"); B:int--String string.valueof (100); (4) Other functions (understanding) conversion (5) new features of JDK5 automatic boxing base type--reference type auto-unpacking reference type--basic type the following code is understood: Integer i = 100; i + = 200; (6) Questions-Data buffer pool problem between 128 and 127 4:character (understanding) (1) Character construction method Character ch = new Character (' a '); (2) The method to be mastered: (self-completion) A: Determine whether the given character is uppercase B: Determine whether the given character is lowercase C: Determine whether the given character is a numeric character D: Turn the given character into uppercase E: turn the given character into Lowercase (3) Case: Counts the number of occurrences of uppercase, lowercase, and numeric characters in a string *\
java--Common class Summary (ii)