An int
is a primitive. Adding a primitive to a string will perform an implicit conversion of that primitive to a String
and add the two strings together. In this case, the int
is converted and ""
( empty String
) is added,
That can be rewritten as:
return Integer.toString(n).contains("1");
or
return String.valueOf(n).contains("1");
or
return String.format("%d", n).contains("1");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…