I have below code which is giving error when i try to access the object's method. What is that i am doing wrong here.
public class Main{
public static void main(String[] args) {
MyFirstObject myObj1 = new MyFirstObject();
MySecondObject myObj2 = new MySecondObject();
MyGenerics mg = new MyGenerics();
System.out.println( mg.partTwo(myObj1, myObj2) );
}
}
class MyFirstObject{
int value(){
return 1;
}
}
class MySecondObject{
int value(){
return 2;
}
}
class MyGenerics {
static <T,U> int partTwo (T o1, U o2)
{
System.out.println(o1.value());
return 1;
}
}
Error is : Main.java:31: error: cannot find symbol System.out.println(o1.value()); ^ symbol: method value() location: variable o1 of type T where T,U are type-variables: T extends Object declared in method partTwo(T,U) U extends Object declared in method partTwo(T,U) 1 error