JavaSE grammar rules

Von Neumann architecture: four parts, including a CPU, a memory,, input and output devices.
jdk (Java Development Kit): Java Development Kit contains javac command.
jre (Java Runtime Environment): Java Runtime Environment, included the java command.
.java files: Java source code files
.class file: Java byte code file
Why use the JVM?
the Java Virtual Machine features: write once, run many
relative paths: for the current directory to the parent directory (..) it is, that path from the current path
absolute path: the path from the beginning letter of
the keyword: public class static void
entry function: public class static void main (String [] args)
class name is a word beginning with a capital letter, if there are more than one word is capitalized word
class name and the file name must be the same
under Window newline is \ r \ n, under Unix is \ n,% n: wrap

System.out.println();//打印并换行
System.out.print();//打印不换行
System.out.printf("%s",........);//按照格式输出
System.out.fomat("%s",........);//同上

Definition rule variables:
variable type variable name;
variable name = value type variable initialized;
if a different type, may involve the type of conversion: explicit and implicit conversion conversion

                  int a=10;// 字面量
                  int a=b;//另一个变量  
                  int a=max(x,y);  //方法的返回值 

Types of variables:
a Basic Type
Value Type:

整型:       byte            1个字节        范围:-128~127
                  short           2个字节
                  int             4个字节
                  long            8个字节 
浮点型:    float           4个字节         
                  double          8个字节                                   
字符类型: char            2个字节(Unicode码点)  1.任何情况下UTF-8
                                                                               2.char 中是中国字  
              布尔类型 :   boolean  true/false    可认为只占一个字节
    二:引用类型
              数组引用,类引用,接口引用

Identifier (comprising variable names, method names, class names) specified:
1) you can start with a letter or $ or (but not start with a digit).
2) can be followed by letters, digits, the underscore
symbol $ dollar.
3) can theoretically infinite length.
4) can not use keywords as identifiers.
Specification
1. Never Chinese as an identifier.
2. Never appear dollar sign $.
3. Do not appear underscore _ in addition to define the variable immutable.
4. The variable names, function all lowercase first word, the other word capitalized, the rest lowercase.
5. The method of naming names with the variable name.

  1. Class name first letter must be capitalized, multiple words, the first letter of each word should be capitalized.
    The default is an integer int, decimal default float. It must use typecast
    long num=235776L;//表示将int 型数字235776转换为long型数据赋值给num

To use the float, must be cast, after adding the decimal F or f

             float a=1.234f;

Type conversion variables:
one, an implicit type conversion: conversion small capacity to large capacity, no need to add any operator.

             int a=5;
            double b=a;
 二, 显式类型转换:也称为强制转换,大容量转为小容量。
             强制转换符:(需要转换成的类型)变量
                   double a=4.95;
                   int b=(int)a;
容量大小:1.byte<short<int <long<float<double;
                  2.char<int <long<float<double;
如果两边类型一样,可以赋值

Error-prone: over the range of types of data loss, hexadecimal 200 is 12C, byte of one byte, hexadecimal two, then lost the front of the 1:00 conversion to decimal output.
Out of 44.

                byte a=(byte)200;//结果44

Operator:
assignment operator: =
arithmetic operators: +, -, *, /,%
! Boolean :( emphasize a role in the Boolean type)
comparison operators: ==,! =,>,> =, <, <=
Ternary operator: Boolean? :
Logical AND or: &&, || (conditions on both sides must be Boolean type)
was specified instanceof determines the type of the variable
~ (bitwise), & (bitwise and) ^ (bitwise exclusive or), | ( bitwise or)

|| having a short-circuit characteristic, the following conditions are true foregoing operation is performed; and | having no short-circuit characteristic

Guess you like

Origin blog.51cto.com/14234314/2421220