--double d = 3; ← You can assign an int type 3 to a double type variable, --String s = "Best" + 3; ← You can concatenate String type and int type. This is because Java automatically evaluates and converts expressions.
The automatic type conversion at the time of assignment seems to be that the value is automatically converted to the box and assigned only when the value of "small type" is assigned to the variable of "large type". As an example
float f = 3;
double d = f;
Even so, when it is output, f is converted to 3.0 and d is also converted to 3.0 and substituted. So, if you put a decimal point in the int type, an error will occur. However, there seems to be a method that can be forcibly assigned ...
int a = (int)3.2;
↑ Instruction to convert 3.2 to int and assign This forced instruction (* int) is called a cast operator.
int a = (int)3.2;
Is output, 3 is displayed. Is this the last resort because you are often asked to be accurate? Is this a fairly used technique ...? I'm scared personally so I don't want to use it (^ o ^)
System.out.println("Ranka");
↑ This is the statement of instruction execution In other words, it is in the form of the name (argument); of the command to be called.
That's why the second chapter is over! After that, I will try the exercises that are prepared. (Because I started working on it earlier than I expected today, w) I haven't been able to memorize it when I get to this point, but I'm excited to be able to write small games using what I've learned ^ _ ^ I was studying with Umesh in one hand today, so I feel tipsy ... Good night (´ ・ ω ゞ)
Recommended Posts