// generics/TupleTest.java// (c)2017 MindView LLC: see Copyright.txt// We make no guarantees that this code is fit for any purpose.// Visit http://OnJava8.com for more book information.import onjava.*;public class TupleTest {static Tuple2<String, Integer> f() {// Autoboxing converts the int to Integer:return new Tuple2<>("hi", 47);}static Tuple3<Amphibian, String, Integer> g() {return new Tuple3<>(new Amphibian(), "hi", 47);}staticTuple4<Vehicle, Amphibian, String, Integer> h() {returnnew Tuple4<>(new Vehicle(), new Amphibian(), "hi", 47);}staticTuple5<Vehicle, Amphibian,String, Integer, Double> k() {return newTuple5<>(new Vehicle(), new Amphibian(), "hi", 47, 11.1);}public static void main(String[] args) {Tuple2<String, Integer> ttsi = f();System.out.println(ttsi);// ttsi.a1 = "there"; // Compile error: finalSystem.out.println(g());System.out.println(h());System.out.println(k());}}/* Output:(hi, 47)(Amphibian@1540e19d, hi, 47)(Vehicle@7f31245a, Amphibian@6d6f6e28, hi, 47)(Vehicle@330bedb4, Amphibian@2503dbd3, hi, 47, 11.1)*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。