In Java, using the following function for a huge matrix X to print its column-distinct elements:
// create the list of distinct values List va
You should use .clear() methods , using this you haven't need to assign memory your variable again and again.