I have learned that Interfaces contain only abstract methods and whatever classes implements these interfaces has to override the methods. In java.lang package,there is an "Interface CharSequence" which has "char charAt(int index)" abstract method.
charAt in following code works fine.in
public class Test {
public static void main(String args[]) {
String s = "Strings are immutable";
char result = s.charAt(8);
System.out.println(result);
}
}
If CharAt is an abstract method, how can anyone use the method and pass arguments without any logic in method(as charAt is an abstract method). Please explain how CharAt abstarct method works without any method body(logic). what is the purpose of having Interfaces in JAVA API if all abstract methods in it must be overridden by programmers with their own logic. Am i missing anything.??