According to my book it is ok! It says if we write <classname>
with the method then we don't need to cast the Object
parameter. Why am I getting the error??
import java.util.*;
interface politics { //interface
void politician(Object obj);
}
class obama implements politics <obama> //class
{
String job;
public void politician(obama p) {
if(p.job.equals("president")) {
System.out.print("You are right Obama is Mr. PRESIDENT");
}
else {
System.out.print("So you say Obama is a "+job.toUpperCase());
}
}
}
class interface2 { //class
public static void main(String args[]) { //main
Scanner in=new Scanner(System.in);
obama o=new obama();
System.out.println("president or citizen?");
String s=in.next();
o.job=s;
o.politician(o);
}
}