Cannot find Symbol method charAt(int)?

We Are Going To Discuss About Cannot find Symbol method charAt(int)?. So lets Start this Java Article.

Cannot find Symbol method charAt(int)?

How to solve Cannot find Symbol method charAt(int)?

charAt is a method that operates on a String.
So example usage would be:
String s = "abc"; System.out.println(s.charAt(0)); //prints out 'a';

Cannot find Symbol method charAt(int)?

charAt is a method that operates on a String.
So example usage would be:
String s = "abc"; System.out.println(s.charAt(0)); //prints out 'a';

Solution 1

charAt is a method that operates on a String.

So example usage would be:

String s = "abc";
System.out.println(s.charAt(0)); //prints out 'a';

Original Author thatidiotguy Of This Content

Solution 2

You need to change condition to

if(letter == getTheword().charAt(0))

ie string should be before the method charAt()

Original Author singhakash Of This Content

Solution 3

charAt() is a method that only works on Strings, as described in the documentation. It returns the char at the given index. Let’s look at a simple example:

String word = "Cow";
char letter = word.charAt(0);
System.out.println(letter);

This will print out the letter (char) “C” to the console, since the letter ‘C’ is at index 0 of the word “Cow”.

So the part where you’re going wrong is that you’re not specifying on which String you want to call the charAt() method.

Original Author D. Visser Of This Content

Solution 4

Try using get instead.

charAt is a method that’s suppoused to operate on strings, while you are operating on an arrayList.

In context:

if(letter == <your arraylist>.get(0).getTheword())

Original Author A. Abramov Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment