It's a declaration of a class Abc
that extends a class DAO
(data access object). The generics part <R extends XYZ>
says that it can be used to insert, update and/or delete objects R
that extend the class XYZ
(most probably a data transfer object). Now, there's no declaration of the R
class. It's just a placeholder to whatever class extending XYZ
.
what does the code snippet Class Abc <R extends XYZ> extends DAO stands for? [closed]
-
10-07-2023 - |
Question
I have code snippet which is as follows:
public class Abc <R extends XYZ> extends DAO{
.
.
.
}
Can someone explain this snippet? Thanks In advance.
Solution
OTHER TIPS
Abc is a subclass of DAO and also includes a generic R which is a subclass of type XYZ
Your class Abc
is a subclass of class type DAO
. This means that the following will compile:
DAO abc = new Abc();
Secondly, your Abc
class has defined a generic type, R
. This type must be a subclass of XYZ
. This means that for any class that can be referred to as XYZ
, can be used to add genericity to this class Abc
.
public class ARGH extends XYZ { }
Abc<ARGH> abc = new Abc<ARGH>();
This means that for any type R
inside Abc
, it will now be of type ARGH
.
public class Abc <R extends XYZ> extends DAO {
R element;
public Abc(R element) {
this.element = element;
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow