Here you can find the source of longestCommonPrefix(String a, String b)
public static int longestCommonPrefix(String a, String b)
//package com.java2s; //License from project: Open Source License public class Main { public static int longestCommonPrefix(String a, String b) { int i = 0; char[] as = a.toCharArray(); char[] bs = b.toCharArray(); int aLen = as.length; int bLen = bs.length; while (i < aLen && i < bLen && as[i] == bs[i]) ++i;//from w w w. j av a2s . c o m return i; } }