String s = "1212*1212";
if(s.indexOf("*") != -1){
   System.out.println("该字符串里包含*");
}

解决方案 »

  1.   

    public class Test
    {
    public static void main(String[] args)
    {
     String s="1337502*2?";
     if(s.indexOf("*") != -1) 
               System.out.println("该字符串里包含*");
        }
    }
      

  2.   

    classjava(原始野人) 完全正确
      

  3.   

    public class Testindex {
       public static void main(String[] args) {
    String s="1337502*2?";
    if(s.indexOf("*") != -1) 
               System.out.println("该字符串里包含*");
    if(s.indexOf("?") != -1) 
               System.out.println("该字符串里包含?");
       }
    }
      

  4.   

    我想楼主是没有说清楚问题,是不是想知道abcdefg中是否包含cde啊?