Constant
What is a constant
* Its value cannot be changed during program execution
Classification of constants in Java
* Literal Constants
* String Constants
* Integer Constants
* Decimal Constants
* Character Constants
* Boolean Constants
* NULL constant NULL (part of the array explained)
* Custom Constants
Eclipse implementation
Class Demo1_constant {public static void main (string[] args) {System.out.println ("abc");//String constant System.out.println (345 );//integer constant System.out.println (3.14);//Decimal constant//system.out.println (' 10 '),//' must be placed in a single character, 10 for 1 characters and 0 characters// System.out.println (");//" is not allowed in anything, because it cannot represent any character System.out.println (");//with a table space character System.out.println (true);// The Boolean class has only two values, True and FalseSystem.out.println (false);}}
In-process
* Decimal
* Binary
* Octal
* Hex
Variable
* In the course of program execution, the amount of its value can change within a certain range
Classification of data types in Java
* Basic Data type
* Integer byte-count range
* Byte one-128 to 127
* Short two -2^15~2^15-1
* int three -2^31~2^31-1
* Long four -2^63~2^63-1
* Floating point type
* Float Single precision
* Double Dual precision
* Character type
* Char
* Boolean type
* Boolean
* Reference Data type
Package Lesson02_poppy_datetypedemo;public class Datetypedemo {public static void main (string[] args) {//byte a=128;/error: Byte the range of data stored in a byte-only storage space is -128~127byte a= (byte) 128; -128, by forcing the type conversion to truncate the leftmost overflow portion of the accuracy of the affected data System.out.println ("a=" +a); System.out.println ("--------------------------");//short b=200;b=500; System.out.println ("b=" +b); System.out.println ("-------------------------");}}
Operator
Classification of operators
* arithmetic operator; assignment operator; comparison (relationship or condition) operator; logical operator; bitwise operator; Trinocular (meta) operator
* Arithmetic operators
a:++,--operator
* Self-plus (+ +) decrement (-) Operation
* + +: self-Add. +1
*--: self-reduction for the original data. 1
* is placed before and after the operand. (This usage is more common to us)
* B: Participating in the operation using:
* is placed in front of the operand, which is either self-increasing or self-decreasing before participating in the operation.
* is placed after the operand, first participating in the operation, Self-increment or self-reduction.
class test1_operator {public static void main ( String[] args) {/*int a = 10;int b = 10;int c = 10;a = b++;//a = 10 ,b = 11c = --a;//a = 9, c = 9b = ++a;//a = 10, b = 10a = c--;//a = 9, c = 8system.out.println ("a = " + a + ",b = " + b + ",c = " + c);*//*int x = 4;//4+6+60int y = (x + + ) + (++x) + (X*10); System.out.println ("x = " + x + ",y = " + y); */byte b = 10;//b++;//b = (Byte) (b + 1) b = b + 1;// When a byte is mixed with int, it is promoted to the int type, the result of the addition of two int or int, the assignment to byte will lose precision System.out.println ("b = " + b);}}
* Assignment operator
* A: Basic assignment operator: =
* Assign the data on the right to the left.
* B: Extended assignment operator: +=,-=,*=,/=,%=
* + = Add the left and right side, then assign to the left.
Class Demo1_operator {public static void main (string[] args) {//assignment operator int a = 5;//assigns a constant value on the right to the left variable, the left must be a variable//a + = 6;//a = A + 6;a = a +6; System.out.println (a);}}
Java Learning Lesson 02