Notes for Learning Java (2)

Source: Internet
Author: User

31. Convert the encapsulated object to the basic data type: obj. XXXValue (); obj is the encapsulated object, and XXX is
Basic data type.
32. Convert from String to basic data type: obj. parseXXX (String str); obj is the object of the encapsulation class, and XXX is the encapsulated object.
The basic data type.
33. Convert a String to an encapsulated object: obj. valueOf (String str ).
34. Convert the encapsulated object to a string: obj. toString ().
35. Convert from basic data type to string: obj. toString (XXX value ).
36. Not equal :! =
37. The instanceof operator, such as v1 instanceof v2. Check whether v1 is an instance of class v2.
38. The formulas on both sides of the logical operator must be boolean. Unlike C ++, integers other than 0 in C ++ are regarded as true.
39. Bitwise logical operators: &, v1 & v2. AND, if the relative bits are both 1, then 1, otherwise 0
|, V1 | v2. Bit OR. If the relative bits are both 0, the value is 0. Otherwise, the value is 1.
^, V1 ^ v2. Bit XOR. If the relative bit has the same value, the value is 0. Otherwise, 1 is returned.
~ ,~ V1. The complement of v1. 1 is changed to 0, 0 to 1.
V1 and v2 must belong to the integer type.
40. Java does not support operation overloading, and does not support the: and> and <operators of C ++.
41. Constant designation: static final int NUM = 1.
42. Array definition: int num []; or int [] num; num = new int [15]; or int [] num = new num [15]; or int
Num [] = {1, 2, 4, 5 };
43. If the length of the 2nd Dimension of a two-dimensional array is different, because the array variable itself is a reference type, you can point the 1st dimension to another array.
44. Copy an array: void arraycopy (Object src, int srcPosition, Object dest, int destPosition, int
Length) or clone () for example int [] newA = (int []) A. clone ();
45. Array operations provided by the Arrays class, such as sorting and searching
Static void sort (dataType [] data): sorts the elements in the array data from small to large (using quicksort)
Static void sort (dataType [] data, int fromIndex, int toIndex)
Static int binarySearch (dataType [] data, dataType key): Searches for array data using binary search
(The key must be sorted in advance. If it is found, the location of the key in data is returned. If it cannot be found, the return value is (-insert

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.