JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Inhert {
@Override
public String toString() {
return "This is an object";
}
}
public class Test<T extends Inhert> {
T obj;
Test(T a) {
this.obj = a;
}
void print() {
/*
here T obj stores an instance of type program why cant i print its field, am i doing somthing wrong?*/
/* for some reason if i put the "i = 20" field in the inherited class "Inhert" it works fine? */
System.out.println(this.obj);
// this.obj.i wont work
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run