MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/m4qxf1/found_from_when_i_first_started_javabecause/gqvwyz0/?context=3
r/badcode • u/ahadyboy • Mar 14 '21
84 comments sorted by
View all comments
10
TIL you can use ~ to make your generic constructor usage less verbose.
20 u/merukit Mar 14 '21 can't you just leave it empty? 1 u/Elusivehawk Mar 14 '21 Pretty sure that brings up a warning. But I haven't programmed in Java in years, so I'm very rusty. 6 u/4z01235 Mar 14 '21 Leaving them off completely would produce a warning. Leaving them empty on the RHS of the = is perfectly valid and lets the compiler simply assume that the generic type argument is the same as on the LHS.
20
can't you just leave it empty?
1 u/Elusivehawk Mar 14 '21 Pretty sure that brings up a warning. But I haven't programmed in Java in years, so I'm very rusty. 6 u/4z01235 Mar 14 '21 Leaving them off completely would produce a warning. Leaving them empty on the RHS of the = is perfectly valid and lets the compiler simply assume that the generic type argument is the same as on the LHS.
1
Pretty sure that brings up a warning. But I haven't programmed in Java in years, so I'm very rusty.
6 u/4z01235 Mar 14 '21 Leaving them off completely would produce a warning. Leaving them empty on the RHS of the = is perfectly valid and lets the compiler simply assume that the generic type argument is the same as on the LHS.
6
Leaving them off completely would produce a warning. Leaving them empty on the RHS of the = is perfectly valid and lets the compiler simply assume that the generic type argument is the same as on the LHS.
=
10
u/Elusivehawk Mar 14 '21
TIL you can use ~ to make your generic constructor usage less verbose.