Java core technology for busy people read the first chapter notes

Source: Internet
Author: User
Basic type constant Static keyword numeric type convert large number string number to string conversion basic type of wrapper class array and array list copy common array algorithm multidimensional array array parameter and return value variable parameter Basic Type4 integer: Int (4 bytes) long (8 bytes, suffix l) short (2 bytes) byte (1 bytes) 2 floating-point type: Float (4 bytes, suffix f) double (8 bytes, default) 1 character types: char (1 bytes) 1 Types of Boolean: Boolean
16 is prefixed with a 0x prefix and a 0b prefix is used in the 2 system. The octal system uses 0 prefixes.
ConstantsConstant names use all uppercase letters final once the value is assigned can not be changed. You can define the post assignment first.
Static keywordUsed to modify a member variable to make it a member of a class, so that all objects are shared with that member, and the member method is modified to be a class method, which can be used directly with the "class name. Method Name"method calls, often used in tool classes; static block usage, with multiple class members initialized together, making the program more regular, which is critical to understanding the initialization of the object; static {Book2 = new book ("Static member BOOK2 member variable Initialization"); BOOK4 = New book ("Static member BOOK4 member variable Initialization"); Static Guide Package usage, import the method of the class directly into the current class, thus directly using the "Method Name"It is more convenient to call class methods. /* Printhelper.java File/* Package com.dotgua.study;
public class Printhelper {
public static void print (Object o) {System.out.println (o);}}
/* App.java File * *
Import static com.dotgua.study.printhelper.*;
public class App. {public static void main (string[] args) {print ("Hello world!");}/**output * Hello world! *///~}

Numeric type conversionsThe conversion order is as follows: 1. If either operand is a double, the other is converted to the double type. 2. If any one of the operands is float, the other is converted to a float type. 1. If either operand is a long type, the other is converted to a long type. 1. If any one operand is of type int, the other is converted to type int.

Large numberBigInteger
BigDecimal
stringString connection: 1. "+" Connection; 2.string.join (",", "str1", "str2", "STR3");
SUBSTRING: str1.substring (7,12); Str1.split (",");
string comparison: Str1.equals (STR2); Do not use the = = operator to compare string = = is the reference address Str.equasignorecase (STR2) that compares two strings; Ignore case when comparing.
conversion of numbers to stringsInteger spin string: integer.tostring (); String-round integer: Integer.parseint (STR1); Double->string:double.tostring (); String->double:double.parsedouble ("3.14");
basic type of wrapper class

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.