Skip to content

Instantly share code, notes, and snippets.

@deepakmehra10
Created July 14, 2019 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakmehra10/3ab2d2ca3605756e329697b0ccee9499 to your computer and use it in GitHub Desktop.
Save deepakmehra10/3ab2d2ca3605756e329697b0ccee9499 to your computer and use it in GitHub Desktop.
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