• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class declaration with generics, and strange constrctor with params  RSS feed

 
Luk Cora
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i lookning a code wrote by someone else, this is


what means the generics placed into class declaration public class Quadrupla<E,T,K,V> ? What kind of vars they are
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you are familiar with generics?
You would declare that class as
Quadruple<String, Integer, LocalDate, String> quad = new Quad<>(...);
That means the first field becomes a String, the second an Integer, etc.
The name Quadruple is misleading. That is not a plain simple tuple, but something designed with a specific purpose in mind, judging by the field names.
The letters E for key and K for value are even more misleading. Is whoever wrote it still there to explain it?
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Quadrupla<E,T,K,V>

Is it possible to use generic with this many parameters?
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tushar Goel wrote:Is it possible to use generic with this many parameters?

Of course it is. You can use even more!
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think i need to check oracle tutorial as well..
 
Luk Cora
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But in IT what is a quadruple??
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A kind of tuple which has four elements. You would not want to specify what particular types they have. Try this Wikipedia article.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!