Java BASICS (12) Summary of common classes (2) and java Basics

Source: Internet
Author: User
Tags float double

Java BASICS (12) Summary of common classes (2) and java Basics

Here are some of the knowledge points and code I summarized in my previous class. Most of the notes I think are very good and classic, sincerely hope that these will help those who want to learn!

It is inconvenient to upload code by module. There are also many things, and they are also clear! If you need it, you can leave your email in the comments. I will certainly send it to you for free! Thank you for making progress on this platform !! Remember that programmers are selfless !!!

Also very welcome to my blog to watch blog address: http://www.cnblogs.com/duscl/

 

 

/* 1: StringBuffer (master) (1) concatenates strings, which is time-consuming and memory-consuming. This concatenation operation is common. To solve this problem, java provides a string buffer class. StringBuffer is used by us. (2) StringBuffer Construction Method A: StringBuffer () B: StringBuffer (int size) C: StringBuffer (String str) (3) common Features of StringBuffer (self-completion method declaration and interpretation) A: Add function B: delete function C: replace function D: reverse function E: Intercept function (pay attention to the returned value) (4) StringBuffer exercises (done once) A: String and StringBuffer convert each other String -- StringBuffer construction method StringBuffer -- String toString () method B: String concatenation C: invert string D: Determine whether a string is symmetric (5) interview question details: StringBuffer: synchronous, data security, low efficiency. StringBuilder: Non-synchronous, insecure data, and high efficiency. A: differences between String, StringBuffer, and StringBuilder B: What are the differences between StringBuffer and arrays? (6) Notes: String is the form parameter, and StringBuffer is the form parameter. 2: array advanced and Arrays (master) (1) sort A: bubble sort the adjacent elements are compared to each other, and the values are placed later. After the first completion, the maximum value appears at the maximum index. Similarly, other elements can be arranged. Public static void bubbleSort (int [] arr) {for (int x = 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 to sort the zero index element, compared with the elements after Index 1, the minimum value of the first time is 0. Similarly, other elements can be arranged. Public static void selectSort (int [] arr) {for (int x = 0; x <arr. length-1; x ++) {for (int y = x + 1; y <arr. length; y ++) {if (arr [y] <arr [x]) {int temp = arr [x]; arr [x] = arr [y]; arr [y] = temp ;}}} (2) search A: Basic Search public static int getIndex (int [] arr, int value) for unordered Arrays) {int index =-1; for (int x = 0; x <arr. length; x ++) {if (arr [x] = value) {index = x; break;} return index;} B: Binary Lookup (half lookup) array Ordering Public static int binarySearch (int [] arr, int 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: is a tool class for Array Operations. Including sorting and searching. B: The method to be mastered (the method to be completed by yourself) converts the array into a string: Sorting: Binary Search: (4) source code parsing of the Arrays tool class (5) sort the characters in the string for example: "edacbgf" result "abcdefg" 3: Integer (master) (1) in order to allow more operations on basic data, java provides the corresponding packaging class type for each basic type byte Byte short Short int Integer long Long float Float double Double char Character boolean Boolean (2) Integer constructor: integer I = new Integer (100); B: Integer I = new Integer ("100"); note: the string here must be composed of digits (3) conversion between String and int A: String -- int Integer. parseInt ("100"); B: int -- String. valueOf (100); (4) Other functions (understanding) hexadecimal conversion (5) new Features of JDK5 auto-boxing basic types -- Reference Type Auto-Unpacking reference types -- Basic types to understand the following code: Integer I = 100; I ++ = 200; (6) interview question-data buffer pool Question 4: Character (understanding) (1) Character constructor Character ch = new Character ('A'); (2) methods To master: (complete by yourself) A: judge whether A given character is capital B: Determine whether A given character is lowercase C: Determine whether A given character is A numeric character D: convert a given character to uppercase E: convert a given character to lowercase (3) case: count the number of times that uppercase or lowercase or numeric characters appear in a string *\

 

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.