public int lengthOfLongestSubstring(String s) {
char[] chars = s.toCharArray();
int sum = 0;
int current = 0;
List<Character> list = new LinkedList<Character>();
if(chars.length == 1)
return 1;
for (int i = 0; i < chars.length; i++) {
if(!list.contains(chars[i])){
list.add(chars[i]);
current = list.size();
if(current > sum)
sum = current;
}else{
list.add(chars[i]);
int index = list.indexOf(chars[i]);
for (int j = 0; j < index; j++) {
((LinkedList<Character>) list).remove();
}
((LinkedList<Character>) list).remove();
}
}
System.out.println(sum);
return sum;
}