num = Integer.parseInt( "39" );
It takes the character string "39", calculates the
int
value,
and assignes that value to the variable num
.
The result is the same as doing this:
num = 39;
Here is the line from the program, again:
num = Integer.parseInt( inData ); // convert inData to int
Assignment statements work in two steps:
In this particular statement, the expression on the right
evaluates to an int
value by using a method call.
Then in the second step that value is assigned to the variable.
This process is usually called converting the characters
to an integer.
Caution: The string inData
is not changed at all.
It is "converted" only in the sense that an integer value is
calculated based on its contents.