Dark Horse programmer--java Learning Note II (grammatical basis)

Source: Internet
Author: User

1, Java programs exist in the form of classes, so you need to tell the virtual machine where to load the class, you can set the CLASSPATH variable. The CLASSPATH variable, if any, indicates that it will also be found in the current directory, and will not be found in the current directory. Of course, if no classpath will be found in the current directory.  2,    rd Delete the directory, plus/s can delete the entire directory, Windows removed from the inside out.  3,     A file has only one public class, the filename must be the same as the class name, and if it is not a friendly class, the same name is not required.  4,    java altogether there are 50 keyword keywords that are defined in the computer language beforehand, with special meaning identifiers, sometimes called reserved words, and variables of special significance. Java's keywords have special meanings for Java compilers, they are used to represent a data type, or to represent the structure of a program, and the keyword cannot be used as a variable name, method name, class name, package name. Java keyword Description List abstract//abstract method, abstract class modifier assert//Assertion condition satisfies Boolean//Boolean data type break//Bounce loop or label snippet byte//8-bit signed data type case// A condition of the switch statement catch//and try with catch exception information Char//16-bit Unicode character data type class//define Class Const//Not used continue//do not execute loop body remainder part default// The default branch do//Loop statement in the switch statement, in which the loop body executes at least once double//64-bit double-precision floating-point number if the other//if condition is not established, the branch enum//enum type extends//is represented as a subclass of another class final/ /indicates that a value cannot be changed after initialization//indicates that the method cannot be overridden, or that a class cannot have a subclass finally//try statement regardless of whether an exception occurred the statement block to execute, float//32-bit single-precision floating-point number for//for loop statement goto// Not using the IF//condition statement implements//Represents a class implemented interface import//import class instanceof//test whether an object is an instance of a class int//32-bit integer number interface//interface, an abstract type, Definition of only methods and constants long//64-bit integer native//representation method implemented with non-Java code new//assigns a class instance to a package//a series of related classes that make up a private///representing a proprietary field, or method, etc. Only accessible from within the class protected//indicates that the field can only be accessed through the class or its subclasses//sub-class or other class in the same package public//Represents a common property or method return//method returns value short//16 digits static//represents at class level definition, all instances shared STRICTFP//floating-point comparison using strict rules super// Represents the base class switch//SELECT statement synchronized//represents a block of code that can only be accessed by one thread at a time this//represents invoking the current instance//or calling another constructor throw//throws an exception throws// Defines a method that may throw an exception transient//adornments do not serialize the field try//represents a code block to do exception handling or a finally mate to indicate whether the thrown exception is executed in the finally code void//Tag method does not return any value volatile// Tag fields may be accessed simultaneously by multiple threads without synchronizing while//while loops    

5, identifier, and Java identifiers consist of numbers, letters (Chinese also can, because of Unicode encoding) and underscores (_), dollar sign ($). is case-sensitive in Java, and also requires that the first digit cannot be a number. Underscores are used mostly in constants, $ in internal classes, in methods, in variable names, and in the name of the hump.

6, comment, single-line comment, multiline comment, document comment. Document Comment/** Start, */end. Multiline comments cannot be nested, so a single-line comment is convenient. Comments will not be compiled into the class file and will be wiped out. The more comments are not the better. 7, write code, do not have to hurry to write code first need to analyze. 1 requirements, 2 ideas, 3 steps. 8, literal constant, Decimal, Integer, Boolean, character, string, null, constant.
 9,     variable when a region in memory space has its own name and type, the region's data can vary. The scope of the variable is valid only in {}.  10,     basic data type and reference data type integer: Byte (8bits-128 ~127) short (16bits-2^16 ~2^16) int (32bits  -2^32 ~2^3 2) long (64bits  -2^64 ~2^64), there is also a class (BigInteger class will replace the range is not large enough), JAVA7 can be added 0b before the binary. You can also underline numeric literals, such as 1_0000_0000, which the Java compiler removes.   Floating-point type: float (32bits 6~7 digits) Double (64bits 15 digits), three special floating-point numbers: positive infinity double (float). positive_infinity, negative infinity large double (Float). Negative_infinity, Double (Float). NaN (cannot detect whether a particular value equals = = it, determine whether two floating-point numbers are equal to be careful), because the error is large, all have a class (BigDecimal) will be replaced. Math.random () returns a random floating-point number (0~1). If you pursue performance with the math Library (Sqrt,pow (x,a), Tan,sin,cos,exp,log, log10 pi,e), otherwise use the Strictmath library.   Character type: char   (16bits)   Boolean type: Boolean (indeterminate size) integer by default: int   decimal default is:double  Interface type: interface class type: CALSS enum type: enum array type:[]  default initialization: int 0, Decimal, 0.0, Boolean false, character: ' \u0000 ', string:null; 11,     Type conversion: Automatic type conversion, two values for two operation, you first need to convert two operands to the same type to recalculate. 1, if there is an operand double, the other operand is automatically converted to DOUBLE.2, if there is an operand of float, the other operand is automatically converted to float.3, if there is an operation long, the other operand automatically turns intoLong.4, otherwise, two operands are converted to int.        forced type conversions, which can lose precision, forcing type conversions to convert floating-point values to integers by truncating fractional parts. If you need to round up with Math.Round (x).  12,     operator precedence, 1,[]. (method call) 2, unary operator 3, two-tuple operator (instanceof) 3, shift operator 4, logical operator  5, bitwise operator (the argument to the right of the shift operator requires a modulo 32 operation (unless the left side is long, the right side is 64 modulo)) 6, Logical operator 7, conditional operator 8, assignment operator 9, comma operator  13,     switch statement features:1. The switch statement chooses only four types: Byte,short,int,char. JAVA7 supports string.
2. Case and default have no order. Executes the first case, without matching case execution default.
3. Two cases of ending the switch statement: ① encounters Break,② execution to the end of the switch statement.
4, if the matching case or default does not have a corresponding break, then the program will continue to execute down, run the statement can be executed until the break or the end of the switch is encountered.
5. After entering the switch statement, the execution order is to execute the case first, then from top to bottom, then the default is executed. Even if default is placed on a case, the order of execution is not changed.  14, loop control statement, for while. Can have a label operation, but must be placed outside the loop to jump out, out of the specified outermost loop, for () can be used to manipulate the expression with commas. For each, you only need to implement the Itreable interface. 15, Function: function is a value call, function Overload:In the same class, more than one function with the same name is allowed, as long as the number of arguments or the type of the parameter are different. Regardless of the return value type, the method name and the parameter type are called the signature of the method.  16, array: The array is allocated on the heap, you can allocate an array of size 0, the array supports for each,int[] buf = {A/z} can only appear at the time of definition initialization.  Array Tool class: Arrays.tostring (t[]) or arrays.deeptostring print array. Arrays.fill (), arrays.copyof (), Arrays.sort (). Arrays.binarysearch ();   

Dark Horse programmer--java Learning Note II (grammatical basis)

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.