Passing char into a method with an int parameter

前端 未结 8 2069
庸人自扰
庸人自扰 2020-12-11 17:38

The output from the following code is 123 because substring takes from beginIndex to EndIndex - 1. However, I am surprised how char

8条回答
  •  醉梦人生
    2020-12-11 17:57

    This is known as implicit casting. The same occurs if you assign an int value to a double. Quick example

        double d = 1;
    

    1 is an int but it is implicitly cast to double (1.0).

提交回复
热议问题