I have studied that
"A class that implements an interface must implement all the methods declared in the interface"
I am doing the study of CharSequence from this link here CharSequence having 4 methods, according to the definition of the interface a class must implement all methods of the interface.
I have created one class and implemented the CharSequence interface
but here I am not overriding the "toString()" method and working fine.
I want to know that my code is not giving any error when I am not overriding the "toString()" but it is giving an error if I am not implementing the others method.
below code is working for me but I think it should give an error.
import java.util.*;
import java.lang.*;
public class Charsequence {
public static void main(String args[]){
System.out.println("hello...");
}
}
class Subsequence implements CharSequence{
public char charAt(int index){
return '1';
}
public int length(){
return 1;
}
public CharSequence subSequence(int start, int end){
return "" ;
}
/*public String toString(){
return "";
}*/
}
sorry for the bad English.
Thank you:)