Skip to content

Instantly share code, notes, and snippets.

@anataliocs
Created September 9, 2019 21:32
Show Gist options
  • Save anataliocs/f64faf128223a324af18a4df05b01a49 to your computer and use it in GitHub Desktop.
Save anataliocs/f64faf128223a324af18a4df05b01a49 to your computer and use it in GitHub Desktop.
toString method to display a well-formatted 2d array in Java
@Override
public String toString() {
return lineSeparator() + Arrays.stream(matrix)
.map(a -> Arrays.toString(a) + lineSeparator())
.collect(Collectors.joining(lineSeparator()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment