Skip to content

Instantly share code, notes, and snippets.

@micycle1
Created October 24, 2018 11:46
Show Gist options
  • Save micycle1/a8c74e5abac5109895eeef9ffc8fde07 to your computer and use it in GitHub Desktop.
Save micycle1/a8c74e5abac5109895eeef9ffc8fde07 to your computer and use it in GitHub Desktop.
Guava ArrayTable from int[]
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
int[] rows = new int[]{1,2,3}
int[] columns = new int[]{4,5,6,7}
List<Integer> row = Arrays.stream(rows).boxed().collect(Collectors.toList());
List<Integer> column = Arrays.stream(columns).boxed().collect(Collectors.toList());
Table<Integer, Integer, Integer> table = ArrayTable.create(row, column);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment