Passing char into a method with an int parameter

前端 未结 8 2103
庸人自扰
庸人自扰 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:45

    so substring's function declaration looks like substring(int startIndex, int endIndex). Now when you pass char it is automatically promoted to integer (endIndex) and hence treated as int.

提交回复
热议问题