Here you can find the source of printMatrix(float[] array, int rows, int columns)
public static void printMatrix(float[] array, int rows, int columns)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.stream.IntStream; public class Main { public static void printMatrix(float[] array, int rows, int columns) { StringBuilder sb = new StringBuilder(); NumberFormat formatter = new DecimalFormat("#0.00"); IntStream.range(0, columns).forEach(i -> { IntStream.range(0, columns) .forEach(j -> sb.append(formatter.format(array[i * columns + j])).append(" ")); sb.append(System.getProperty("line.separator")); });//from ww w.ja v a 2s . c o m System.out.println(sb.toString()); } }