Can someone help me?!
With the input abcfbc abfcab it is supposed to give me 4(exludes the redudant characters) but it gives 9 import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub int max=1000; System.out.println("enter a string"); Scanner sc=new Scanner(System.in); String string1=sc.nextLine(); if(string1.length()>max) string1=string1.substring(0,max); String []string2=string1.split(" ",2); String sequence1=string2[0]; String sequence2=string2[1]; String sequence3=""; int sum=0; char [] red=new char[1]; for(int i=0;i<sequence1.length();i++) { for(int j=0;j<sequence2.length();j++) { red[0]=sequence2.charAt(j); if(sequence1.charAt(i)==red[0]&&sequence3.contains(red.toString())==false) sequence3=sequence3+red[0]; } } System.out.println(sequence3.length()); } }