打印二维数组中的特定行 [英] Print Specific Row in 2D Array

查看:51
本文介绍了打印二维数组中的特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在这个 4x4 数组中只打印第二行?

How would I get just the second row to print in this 4x4 array?

double [][] table = new double[4][4];

for(int i = 0; i < table.length; i++){
 for(int j = 0; j < table[i].length; j++)
  table[i][j] = (Math.random() * 10);
}

推荐答案

使用这个

for(int j = 0; j < table[1].length; j++)
   System.out.print(table[1][j]+" - ");

这篇关于打印二维数组中的特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆