给出方法者给分

解决方案 »

  1.   

    我的意思是说如String a="1,1075,1046,1085",String b="1,1085";想要知道b包含在a里面怎么个算法??
    这里的字符串都是以逗号隔开,且是有规律的数字,
      

  2.   

    int k=a.indexOf(b); (在里面的k将显示出位置,不在里面的k值为-1)
      

  3.   


    public class AA {  
    public static void main(String[] args)
    {
    String a="1,1075,1046,1085";
    String b="1,1046";

    System.out.println(a.contains(b.subSequence(1,6)));
    }
    }
    ^_^,多查一下文档就可以了!
    subSequence
    public CharSequence subSequence(int beginIndex,
                                    int endIndex)
    Returns a new character sequence that is a subsequence of this sequence. 
    An invocation of this method of the form  str.subSequence(begin, end)
    behaves in exactly the same way as the invocation 
     str.substring(begin, end)
    This method is defined so that the String class can implement the CharSequence interface. 
    Specified by:
    subSequence in interface CharSequence
    Parameters:
    beginIndex - the begin index, inclusive.
    endIndex - the end index, exclusive. 
    Returns:
    the specified subsequence. 
    Throws: 
    IndexOutOfBoundsException - if beginIndex or endIndex are negative, if endIndex is greater than length(), or if beginIndex is greater than startIndex
    Since: 
    1.4 contains
    public boolean contains(CharSequence s)
    Returns true if and only if this string contains the specified sequence of char values. Parameters:
    s - the sequence to search for 
    Returns:
    true if this string contains s, false otherwise 
    Throws: 
    NullPointerException - if s is null
    Since: 
    1.5 
      

  4.   

    建议楼主看一下《java参考大全》,对部分知识介绍的比较详细
      

  5.   

    String str1="abcdefghccc";String str2="def";miuko:for(int i=0;i<str1.length();i++){  if(i+str2.length()>str1.length())     break miuko;  String str=str1.substring(i,(str2.length()+i));  if(str==str2)   System.out.println("两字符串有包含关系"); }
      

  6.   

    使用StreamTokenizer ,你可以看文档关于StreamTokenizer的用法。
      

  7.   

    String[] c=b.split(",");
    boolean bIn=true;
    for(int i=0;i<c.length;i++)
    {
        if(a.indexOf(bIn[i])==-1
        {
           bIn=false;
           break;
        }
    }
    if(bIn)
       ......
    else
       ......
      

  8.   

    String a="1,1075,1046,1085",String b="1,1085";//想要知道b包含在a里面怎么个算法??
    String[] str=new String[2];
    int i=0;
    while (b.indexOf(","))
    {
    str[i]=b.substring(0,b.indexOf(","));
    b=b.substring(b.indexOf(",")+1);
    i++;
    }
    for (int j=0;j<str.length() ;j++ )
    {
                      if(a.indexOf(str[j])!=-1)
                      
    System.out.println("位置再"+a.indexOf(str[j])); }
      

  9.   

    String a="1,1075,1046,1085",String b="1,1085";//想要知道b包含在a里面怎么个算法??
    String[] str=new String[2];
    int i=0;
    while (b.indexOf(","))
    {
    str[i]=b.substring(0,b.indexOf(","));
    b=b.substring(b.indexOf(",")+1);
    i++;
    }
    for (int j=0;j<str.length() ;j++ )
    {
                      if(a.indexOf(str[j])!=-1)
                      
    System.out.println("位置再"+a.indexOf(str[j])); }