Summary of Java Fundamentals (i)

Source: Internet
Author: User

1. Bubble sort: (interview often)

Static voidBubblesort (int[] a) {inttemp;  for(inti = 0; i < a.length-1; i++) {             for(intj = 0; J < A.length-1; J + +) {                if(a[j]>a[j+1]) {temp=A[j]; A[J]=a[j+1]; A[j+1]=temp; }                                }            }}

2.String processing String Common methods

int length ();--Get string length-----and set distinguish, int size ();

int indexOf (string str);--Returns the first occurrence of the index in this string

Boolean equalsignorecase (String another);--Comparison of two strings, case-insensitive-----Verification Code

String subString (int beginindex) gets a string, starting from Beginindex to the end

String subString (int beginindex,int endIndex) Gets a string, starting at Beginindex to the end of EndIndex (not including the character EndIndex)

String[] Split (string regex) splits the string, returning the segmented array of strings

3. Inheritance, encapsulation, multi-state Simple summary

Inherited:

Code reuse is implemented through inheritance. All classes in Java are obtained by inheriting the Java.lang.Object class directly or indirectly.
Inherited classes are called subclasses, and inherited classes are called parent classes. Subclasses cannot inherit member variables and methods in the parent class that have access rights private.
Subclasses can override the parent class's methods and name member variables with the same name as the parent class.
However, Java does not support multiple inheritance , which is the ability of a class to derive from multiple classes of superclass.

Encapsulation: Property privatization, providing getter and setter access to private properties ----common

three prerequisites for polymorphic presence :
First, to have inheritance;
Second, to have a rewrite;
The parent class reference points to the subclass object.

4. Eight Package classes

5. Packing and unpacking:

Http://www.cnblogs.com/dolphin0520/p/3780005.html

Summary of Java Fundamentals (i)

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.