Java String Sub String substr(String substr1, String substr2)

Here you can find the source of substr(String substr1, String substr2)

Description

substr

License

Open Source License

Declaration

public static String substr(String substr1, String substr2) 

Method Source Code

//package com.java2s;

public class Main {
    /** @METHOD */
    public static String substr(String substr1, String substr2) {
        String substr = "";
        int size = Math.min(substr1.length(), substr2.length());

        for (int i = 0; i < size; i++) {
            if (substr1.charAt(i) == substr2.charAt(i))
                substr += substr1.charAt(i);
            else//from  w  w w  .j ava2s  . c  o m
                break;
        }
        return substr;
    }
}

Related

  1. subStr(String str, int len)
  2. substr(String str, int length)
  3. subStr(String str, int limit)
  4. subStr(String str, int maxLen)
  5. substr(String str, int startIndex, int length)
  6. substr(String what, int begin, int end)
  7. substr(StringBuffer buf)
  8. substract(double[] a, double[] b)
  9. substract(double[] a, double[] b)