This method returns true
if the number passed in contains a 1
.
public boolean hasOne(int n) {
return (n + "").contains("1");
}
What is the purpose of the + ""
part? How does that make n
a string
? (.contains
only works with Strings
as far as I understand).