[Solved] Can’t figure out what is wrong with my code


I figured the problem that your code is not able to compare the last character.It expects a space after the last character so that it can compare the last character since java doesn’t use null character terminator for string termination.I have emulated the same code using Scanner class as I was having some trouble with io.So I have done the following change:

         Scanner sc1,sc2;
        sc1=new Scanner(System.in);
         String input = sc1.nextLine()+" ";

I don’t know if its possible to do:

String input = IO.readString()+" ";

but i think you should try appending blank space ” ” at the end of the string

0

solved Can’t figure out what is wrong with my code