Java Basic Questions

Source: Internet
Author: User
Tags wrapper

1.java compile and run process---can draw detailed

2.JDK, JRE, JVM three relationships

3.8 Basic types and range of values--complement introduction https://wenku.baidu.com/view/d17dd4ba1a37f111f1855b10.html

4. Conversions between basic types

5.switch starting from jdk1.7 support string as expression: Principle http://blog.csdn.net/queenjade/article/details/44778653

6. Initialize the array:

Attention:

Int[] A = new int[]{1,23};
Int[] b= {n};
Int[] C;
c = new Int[5];

If it is written:

Int[] A = new int[2]{1,23};

Int[] C;
c = {n};

is the wrong wording.

Array replication: system.arraycopy (src, Srcpos, dest, Destpos, length), and arrays.copyof (original, newlength);

Some methods of StringBuilder should be mastered skillfully.

String, StringBuilder, stringbuffer differences

string comparison:

String S4 = "123abc", and string S5 = "123" + "ABC"; the two are the same, and they are literally added directly. So it's possible. And if

String s6 = "123";
String s7 = s6+ "abc";

Then S7 and S4 are different.

Override the Equals method code to be proficient.

equals and = = differ.

The wrapper class is an immutable class. Note the basic types of the eight wrapper classes and the differences between the parent classes.

Common methods for packaging classes.

The principle of automatic unpacking and boxed code implementation. Integer.valueof (+); int a = B.intvalue ();

SimpleDateFormat method: SimpleDateFormat sdf = new SimpleDateFormat ("Yyyy-mm-dd HH:ss:mm");D ate Date = Sdf.parse (string); String str = sdf.format (date);

The application of the calendar method.

Set common methods to master. such as IsEmpty ().

A connection between a collection and an iterator and a code implementation.

Iterators cannot be removed using the remove of the collection when they are deleted and must use the Remove method of the iterator.

The generic Test-center is not clear at the moment.

Application of List.get (index) and List.set (index,element) elements. List.set (1,list.set (3,list.get (1)), for example, represents the interchange of 1 and 3-bit elements, noting that the set method returns the elements of the original position.

The list is converted to an array:

String[] strings = (string[]) List.toarray (), must be strong, or error.

string[] str = list.toarray (new string[]{});

The array is converted to a collection:

list<string> list = arrays.aslist (array);

Note: A collection that is converted from an array is not able to add elements or delete elements because this causes the array to be expanded or shrunk, which means that the original array cannot be represented. However, you can modify the value of the element.

Comparable interface: The analogy of the comparison is that the cell must implement the interface, and then rewrite the method it calls. int CompareTo (Cell o) {}; Collections.sort (cells); compare result return value, >0 <0 =0

Comparator interface: The class that writes a comparator directly implements the comparator interface interface, overriding its method int compare (T t1,t t2) {}; then, Collections.sort (Cells,comparatorclass);

Notice that in comparator it declares that its type is string

Class Mycomparator implements comparator<string>{
/**
* Comparison rule: The big word than characters
*/
public int Compare (string O1, string O2) {
Return O1.length ()-o2.length ();
}
}

Map and interview with HashMap.

Java Basic Questions

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.