45ms. accepted. java. different method. Is there some advice?

nice idea to avoid judging empty string..and similar to mine:)
public class Solution {
public int lengthOfLongestSubstring(String s) {
int start=0;
int end=1;
int max=1;
int len=s.length();
if(len==0)
return 0;
while(end<len){
int pos=s.substring(start,end).indexOf(s.charAt(end));
if(pos!=1){
start+=pos+1;
end++;
}else{
end++;
}
max=Math.max(max,endstart);
}
return max;
}
}