问问题
102 次
2 回答
1
Not sure exactly what you are trying to accomplish here, but bit shift left is the same as saying multiply by two. So if you want to get the "next" integer with the same "substring" you just multiply by two.
3: 11
*2=
6: 110
18: 10010
*2=
36: 100100
于 2012-07-11T15:01:45.350 回答
0
Making a bit of jump on your methodology :P but you could convert the number to a string and use some sort of find method. It doesn't do it via math? but it gets the job done
public static void main(String[] args){
Integer myNum = 1010;
String myNumString = Integer.toString(myNum);
System.out.println(myNumString.matches(".*10.*"));
}
于 2012-07-11T15:16:55.233 回答