Created
July 14, 2019 07:14
-
-
Save deepakmehra10/3ab2d2ca3605756e329697b0ccee9499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TupleDemo { | |
public static void main(String[] args) { | |
Tuple2<Integer, Integer> tuple2 = Tuple.of(1, 2); | |
System.out.println(tuple2._1); // to retrieve first value from Tuple | |
System.out.println(tuple2._2); // to retrieve second value from Tuple | |
System.out.println(getStatus()); // function returning multiple values with the help of Tuple | |
Tuple2<String, String> transformedTuple = getStatus().map(first -> first.concat(" 403"), | |
second -> second.concat(" 200")); // transforming values of a tuple | |
System.out.println(transformedTuple); | |
} | |
private static Tuple2<String, String> getStatus() { | |
return Tuple.of("Rejected", "Passed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment