2015-09-07 11:44:36 -06:00
|
|
|
// generics/TupleTest2.java
|
2021-01-31 15:42:31 -07:00
|
|
|
// (c)2021 MindView LLC: see Copyright.txt
|
2015-11-15 15:51:35 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2015-11-11 20:20:04 -08:00
|
|
|
import onjava.*;
|
|
|
|
import static onjava.Tuple.*;
|
2015-06-15 17:47:35 -07:00
|
|
|
|
|
|
|
public class TupleTest2 {
|
2015-11-11 20:20:04 -08:00
|
|
|
static Tuple2<String, Integer> f() {
|
2015-06-15 17:47:35 -07:00
|
|
|
return tuple("hi", 47);
|
|
|
|
}
|
2015-11-11 20:20:04 -08:00
|
|
|
static Tuple2 f2() { return tuple("hi", 47); }
|
|
|
|
static Tuple3<Amphibian, String, Integer> g() {
|
2015-06-15 17:47:35 -07:00
|
|
|
return tuple(new Amphibian(), "hi", 47);
|
|
|
|
}
|
|
|
|
static
|
2015-11-11 20:20:04 -08:00
|
|
|
Tuple4<Vehicle, Amphibian, String, Integer> h() {
|
2016-01-25 18:05:55 -08:00
|
|
|
return tuple(
|
|
|
|
new Vehicle(), new Amphibian(), "hi", 47);
|
2015-06-15 17:47:35 -07:00
|
|
|
}
|
|
|
|
static
|
2017-05-10 11:45:39 -06:00
|
|
|
Tuple5<Vehicle, Amphibian,
|
|
|
|
String, Integer, Double> k() {
|
2015-06-15 17:47:35 -07:00
|
|
|
return tuple(new Vehicle(), new Amphibian(),
|
|
|
|
"hi", 47, 11.1);
|
|
|
|
}
|
|
|
|
public static void main(String[] args) {
|
2015-11-11 20:20:04 -08:00
|
|
|
Tuple2<String, Integer> ttsi = f();
|
2015-06-15 17:47:35 -07:00
|
|
|
System.out.println(ttsi);
|
|
|
|
System.out.println(f2());
|
|
|
|
System.out.println(g());
|
|
|
|
System.out.println(h());
|
|
|
|
System.out.println(k());
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
}
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
(hi, 47)
|
|
|
|
(hi, 47)
|
2021-01-31 15:42:31 -07:00
|
|
|
(Amphibian@a298b7, hi, 47)
|
|
|
|
(Vehicle@16d3586, Amphibian@154617c, hi, 47)
|
|
|
|
(Vehicle@17327b6, Amphibian@14ae5a5, hi, 47, 11.1)
|
2015-09-07 11:44:36 -06:00
|
|
|
*/
|