字符串与子字符串比较

时间:2015-07-22 11:05:29

标签: java android

我已经使用了两个字符串native =" +8801723519932" ,和本地=" 01723519932" , 如何在strings"更改"中将两个+88variable进行比较?来自本地人。不使用substring

2 个答案:

答案 0 :(得分:0)

native = "+8801723519932"
local = "01723519932"
change = ?

**Compare both strings:-** 

if(native.equals(local)){
   System.out.println("Match");
}else{
   System.out.println("Not Match");
}

**Get +88 from given string without using subString.**

if(native.indexOf("+88")>=0){
   System.out.println("+88");
}

答案 1 :(得分:0)

public class a {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    String nativea="+8801723519932";
    String local = "01723519932";

    String str[]=nativea.split(local);
    for (int i = 0; i < str.length; i++) {
        String string = str[i];
        System.out.println(string);
    }
      }

   }