Topic: 字符二维数组赋值

  Print this page

1.字符二维数组赋值 Copy to clipboard
Posted by: ruijie_zhao
Posted on: 2005-09-30 00:30

String[][] row_content=new String [3][4];
for(i=0;i<3;i++)
{


row_content[i]={"sss"}; //请教如何给值?,怎么样使二维可以用一维的形式表现

}

2.Re:字符二维数组赋值 [Re: ruijie_zhao] Copy to clipboard
Posted by: ruijie_zhao
Posted on: 2005-09-30 10:03

没有人知道么??

3.Re:字符二维数组赋值 [Re: ruijie_zhao] Copy to clipboard
Posted by: bluecrystal
Posted on: 2005-09-30 12:26

测试代码:


public class Test{
//静态数组初始化
static String[][] strs = {
   {"a", "b", "c"},
   {"A", "B", "C"},
};
public static void main(String[] args){
String[][] row_content=new String [3][4];
  for(int i=0; i<3; i++)
  {
for(int j=0; j<4; j++) {
      row_content[i][j]=(new StringBuffer()).appendLight Bulb.append("_").append(j).toString();
      System.out.print(row_content[i][j]);
      System.out.print(" ");
    }
    System.out.print("\r\n");
  }

for(int i=0; i<strs.length; i++)
  {
for(int j=0; j<strs[i].length; j++) {
      System.out.print(strs[i][j]);
      System.out.print(" ");
    }
    System.out.print("\r\n");
  }   
}
}


输出:

0_0 0_1 0_2 0_3
1_0 1_1 1_2 1_3
2_0 2_1 2_2 2_3
a b c
A B C

Smile

4.Re:字符二维数组赋值 [Re: ruijie_zhao] Copy to clipboard
Posted by: ruijie_zhao
Posted on: 2005-09-30 13:13

谢谢

5.Re:字符二维数组赋值 [Re: ruijie_zhao] Copy to clipboard
Posted by: ranchgirl
Posted on: 2005-09-30 13:27

To bluecrystal

In your favorite editor, please select space replace tab option. Except nodepad, almost all editors have this option.

Most companies I have worked have very strict rule on that.

Thanks!

6.Re:字符二维数组赋值 [Re: gongshi] Copy to clipboard
Posted by: bluecrystal
Posted on: 2005-09-30 13:32

gongshi wrote:
To bluecrystal

In your favorite editor, please select space replace tab option. Except nodepad, almost all editors have this option.

Most companies I have worked have very strict rule on that.

Thanks!

ok
我使用的editplus,把这个选项钩上
Smile

7.Re:字符二维数组赋值 [Re: gongshi] Copy to clipboard
Posted by: zcjl
Posted on: 2005-09-30 14:53

gongshi wrote:
To bluecrystal

In your favorite editor, please select space replace tab option. Except nodepad, almost all editors have this option.

Most companies I have worked have very strict rule on that.

Thanks!


这是一个比较好的习惯,^_^


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923