user11731595 :
I need to create an objects what l may to check by instanceof
keyword.
Like
public class Example {
private int create(GUIItemType type){
if(type instanceof GUIItemTypeCommand){
return 0;
} else if (type instanceof GUIItemTypeSend){
return 1;
} else {
return 2;
}
}
}
Whay i need use for create that? GUIItemTypeCommand class must extends GUIItemType class? GUIItemType class must be abstract?
Arvind Kumar Avinash :
You can create GUIItemType
as an interface
and then make GUIItemTypeCommand
and GUIItemTypeSend
implement it.
interface GUIItemType {
// default methods, abstract methods, public static final variables
}
class GUIItemTypeCommand implements GUIItemType {
}
class GUIItemTypeSend implements GUIItemType {
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=393687&siteId=1