First of all, I learned that:
- You cannot instantiate an Interface
- An Interface doesn't implement its functions
After seeing the following Java code:
public class MyClassTest {
public static void main(String[] args) {
// String to CharSequence?
CharSequence c = "Java";
System.out.println(c);
System.out.println(c.length());
}
}
I am very confused when I learned that CharSequence
is an Interface
How can you use an Interface like an object and initialize it?
Why does
CharSequence
implements alength
function if its an interface?