Java hands-on brain
1. Enumtest.java Example
The results of the Enumtest.java operation are as follows
Run result analysis: Enum type is a reference type and is not part of the original data type.
Conclusion: An enumeration type is a reference type and is not part of the original data type, and each of its specific values refers to a specific object. The same value refers to the same object.
You can use the "= =" and the Equals () methods to directly compare the values of the enumeration variables, in other words, the result of the "= =" and the Equals () methods are equivalent for variables of enum types.
2. Testdouble.java Example
Testdouble.java Running Results
Results analysis: The conversion between some types, the accuracy will be missing. So the same data needs to be converted to multiple types, and this data needs to be used for a longer period of time, and in most cases it is recommended to use coercion type conversions directly.
Conclusion: The result of the calculation using a double type of numerical value is imprecise.
3. What is the output of the following code?
int x=100;
int y=200;
System.out.println ("x+y=" +x+y);
System.out.println (x+y+ "=x+y");
Why is there such an output result?
Operation Result:
Results analysis: System.out.println ("x+y=" +x+y); this line of code output 100200 is because the computer reads the code is in order, to output is "x+y=", the back of the +x is 100, and then a +y is 200, so the last output X +y=100200, while System.out.println (x+y+ "=x+y"); x+y=100+200=300, the final output results.
Conclusion: In addition to the assignment operator =, all the binding is left to right.
4. Hands-on brain:
Look at this figure, and look at the number of bits in Java for each data type, and the range of values that you can draw.
Conclusion: The loss of information may be caused by coercion of type conversions.
Hands on the brain