a place for you as a java learner and anyone interesting in programming.
Pages
Home
Tips for java dummies
ASk Your Question ?
Wednesday, 4 May 2016
Static methods can be generic
class
Test
{
static
<
T
>
T identity
(
T t
)
{
return
t
;
}
public
static
void
main
(
String
[]
args
)
{
String
s
=
Test
.<
String
>
identity
(
"Hi"
);
System
.
out
.
print
(
s
);
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment