Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial2 Answers
Seth Kroger
56,413 PointsYou're asking the question in Java Basics but the concepts involved in answering are covered in subsequent courses. A CharSequence is an interface, not a class. This means that it's methods are empty on it's own and it's up to the implementing class to fill them out. It basically means that any class that implements CharSequence will supply the stated methods. You don't be able to create a CharSequence on it's own directly, only through creating an instance of an implementing class. These classes include String as well as others like StringBuilder, Android's Editable, etc.
Unsubscribed User
3,074 PointsThey are both mostly the same. I guess you would use one over the other depending on what you want to do with the variable. The String datatype looks like it is more versatile when it comes to the methods that can be run on it. Refer to the documentation below
https://docs.oracle.com/javase/7/docs/api/index.html?java/lang/String.html
https://docs.oracle.com/javase/7/docs/api/index.html?java/lang/CharSequence.html