Home > Back-end >  If a method is introduced into different kinds of parameters, can get the id attribute
If a method is introduced into different kinds of parameters, can get the id attribute

Time:03-06

Assume that there are three types of classA and classB, classC, three class has an id attribute, there is A way need to pass in A, B, C among them any one, to get their id
 
Public void test (T T) {
T.g etId ();
}

Probably need to implement such a function code, consult

CodePudding user response:

Don't know what topic main want to express

CodePudding user response:

Is probably a generic into how refs call getId ()

CodePudding user response:

The parent class or interface

CodePudding user response:

{
 interface idString getId(); 
}

The public & lt; T extends id> Void test (T T) {
T.g etId ();
}

CodePudding user response:

Either extract into public class or interface. Or they use reflection!
  • Related