java learning day2

Constant
Definition : The quantity whose value cannot change during the execution of the program
Classification:
1. Literal constants:
integer constants: 1, 2, 3
Decimal constants: 1.1, 1.2
Character constants (must use single quotation marks): 'a' ,'b','c','i'
String constants (must use double quotes): "abcdefg"
Boolean constants (true and false, true and false): true and false
All constants can be printed out
2, java There are four representations for integer constants
Binary
Octal
Decimal
Hexadecimal
==================================== =========================
Variable
Definition : A quantity whose value can change within a certain range during the execution of a program,
like an unknown in mathematics
Define variables
Fixed format: 1. Data type variable name = assignment (specific value)
          2. Data type variable name;
             variable name = assignment
          = The data type of the following value is consistent with the previously defined data type, and the
data type acts as a constraint variable The role of value In the
java language, each data must have a data type, and there is a strict distinction between each data
Data types: basic data types and reference data types
Reference  data types: 1, class class
              2, interface
              3, array[] 
basic data types: 1, integer byte short int long
              2, decimal float double
              3, character char
              4, boolean The boolean
string does not belong to the basic data type. The
variable can be printed out
. The integer constants that appear in the java program are the default data type of the int type
            . The default data type is the double type. If the
double data is assigned to the float
data Type conversion Conversion
from small data to big data is called natural conversion Conversion


from big data to small data is called forced conversion
Target data type variable name = (target data type) converted data
byte short char As long as it participates in the operation, it will be automatically promoted to int type
Large Data and small data operations will be upgraded to large data types. The plus sign after the
printed output string indicates the connection. The string has an assimilation function, which will assimilate the data connected to it into a string.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325825070&siteId=291194637