public class Enumtest {
public static void Main (string[] args) {
Size S=size.small;
Size T=size.large;
S and T refer to the same object?
No
System.out.println (s==t); //
is the original data type?
No, reference type
System.out.println (S.getclass (). isprimitive ());
Convert from String
Size u=size.valueof ("SMALL");
System.out.println (S==u); True
List all of its values
For (Size value:Size.values ()) {
System.out.println (value);
}
}
}
Enum Size{small,medium,large};
Analysis:
As for the result of this function, the first two false and true are indications of the correctness or not of the output, and three successive SMALL MEDIUM that appear later LARGE is the Loop for (Size value:Size.values ())
{
System.out.println (value);
}
To achieve, through
For (Size value:Size.values ())
all variables in the size type can be output sequentially.
2. the basic concept of anti-code, complement and original code
( 1 ) Original Code : The binary form of this number itself
(2) Anti-code
The inverse of a positive number is its original code, and the inverse of the negative is to its original code in addition to the sign bit outside of the negation of you.
( 3 ) Complement
The complement of a positive number or its original code, but the complement of the negative is the original code in addition to the symbol bit outside the counter after the end of the next plus 1 .
3. The computer can only recognize the binary, all the data will be converted to binary at the end. For example, in the source program 401.5 is decimal, to be converted to binary, but 401.5 binary is not accurate 401.5, just close 401.5, real 401.499999999999, floating-point number consists of two parts: exponent and mantissa, when the binary and decimal conversion of floating-point numbers, floating-point numbers participate in the calculation, Then the process of conversion becomes unpredictable and becomes irreversible.
4. The plus sign after the string is the function of the connection, that is, the plus sign after "X+y" automatically converts the X to the string , so and X becomes a string.
Similarly, the plus sign after X converts Y to a string , so the final output is "x+y=" 100200
Because there is no string in front of x, x and Y must first perform the normal addition operation, so the final output is 300=x+y
Hands-on brain after class practice