String的indexof的使用

public class Test8 {

public static int getNum() {
int num = 555667;
boolean b = true;
int temp = 1;
int he = 0;
while(b){
temp++;
he = num*temp;
String str = he+"";
//indexof 就是看str包含不包含这个数字 包含不等于-1
if(str.indexOf("1") != -1){
if(str.indexOf("2") != -1){
if(str.indexOf("3") != -1){
if(str.indexOf("4") != -1){
if(str.indexOf("5") != -1){
if(str.indexOf("6") != -1){
if(str.indexOf("7") != -1){
if(str.indexOf("8") != -1){
if(str.indexOf("9") != -1){
return he;
}
}
}
}
}
}
}
}
}
}
return 0;
}

public static void main(String[] args) {
System.out.println(Test8.getNum());
}
}

原文地址:https://www.cnblogs.com/flord/p/5961589.html