- public class Matrix {
- //创建类
- public static void main(String[] args) {
- //主方法
- char a[][] = new char[3][4];
- //定义二维数组
- for (int i = 0; i < a.length; i++) {
- for (int j = 0; j < a[i].length; j++) {
- //循环遍历数组中的每个元素
- a[i][j]='*';
- //初始化数组内容
- System.out.print((char)a[i][j]);
- //将数组中的元素输出
- }
- System.out.println();
- //输出空格
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/1301201614424.html
来源: http://www.codesnippet.cn/detail/1301201614424.html