I am now studying JAVA. When we make interface like this, sometimes we create object like this
Sample code :-
interface test01{
public boolean A(int i);
public int B(int a);
public String C (String c);
}
class ttt implements test01{
public boolean A(int a){
return true;
}
public int B(int a){
return a;
}
public String C(String c){
return c;
}
}
public class Interface_test {
public static void main(String[] args) {
ttt t1 = new ttt();
System.out.println(t1.A(1));
System.out.println(t1.B(1));
System.out.println(t1.C("C"));
test01 tt = new ttt();
System.out.println(tt.A(1));
System.out.println(tt.B(1));
System.out.println(tt.C("C"));
}
}
This code's result is same but I was wondering why we use the pattern like this
"test01 tt = new ttt();"
instead of
"ttt t1 = new ttt();"
Please let me know...
Thank you!