-2
    import java.util.Arrays;

public class Caesar {
    public static void  main (String[] args) {
       
        //user input
        String [] input= {"bbcc"};

        // turn user input from string to char, creates array.
        char [] charinput = input.toCharArray();

        // Arrays decleration
       char [] abc={'a','b','c','d'};
       char [] ABC={'A','B','C','D'};
/*
       for (int i = 0; i <abc.length; i++){
            // code to check if a char in string is in array abc

        }
*/
    }
}

why do I still get the error "Cannot resolve method 'toCharArray' in 'String'"? I looked for solution on line but all I found was to add "import java.util.Arrays;" and then it should work but it still doesn't.

MeepMeep
  • 1
  • 3
  • 4
    Because input is an array not a single value – Boris the Spider Nov 21 '21 at 11:07
  • Are you sure the error message is not `Cannot resolve method 'toCharArray' in 'String[]'`? The `[]` at the end is important. `String` and `String[]` are different types with different methods. – VGR Nov 21 '21 at 13:20

1 Answers1

0

As you are using String array , toCharArray is not present.

Change it to:-

        //user input
        String input= "bbcc";

        // turn user input from string to char, creates array.
        char [] charinput = input.toCharArray();

This should work.

Manas
  • 11
  • 3