-2

Whether I try to change a textView or a button, why does Android Studio require that I pass only chars and not strings in the setText() method?

1 Answers1

0

Strings are automatically converted to CharSequences when necessary (or are CharSequences; can't remember. The point is, they're compatible):

public class Main {
    public static void testF(CharSequence seq) {
        System.out.println(seq);
    }

    public static void main(String[] args) {
        testF("Hello"); // Prints "Hello" 
    }
}

This would have been a good thing to try on your own or search for first.

Carcigenicate
  • 43,494
  • 9
  • 68
  • 117