Software NetBeans IDE 7.0.1, need to write the main class alone.
Packaging a class CommonPrefix, the method comprising a return of the two string arguments prefix shared public String getPerx (String sl, String s2). For example: "disappear, and" distance "of a total prefix" is, if not an empty string. Packaging executes the main class.
Main categories:
CommonPrefix c=new CommonPrefix();
c.getPrefix("aaaaff", "aaaava");
CommonPrefix categories:
public class CommonPrefix {
public String getPrefix(String s1,String s2){
char[] a=s1.toCharArray();
char[] b=s2.toCharArray();
int length1=a.length;
int i;
for(i=0;i<a.length;i++){
if(a[i]==b[i]){
System.out.print(a[i]);
}
else{
return null;
}
}
return " ";
}
}