Topic: 数组求助

  Print this page

1.数组求助 Copy to clipboard
Posted by: ch0707
Posted on: 2007-09-20 08:33

package class1;

public class Welcome {

  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
String[] greeting = new String[3];
greeting[0] = "AA爱学习!";
greeting[1] = "BBB爱学习!";
greeting[0] = "AA和BBB都爱学习!";

for(String s : greeting){
  System.out.printlnMoon;
}
  }

}

为什么显示的答案是:
AA和BBB都爱学习!
BBB爱学习!
null

2.Re:数组求助 [Re: ch0707] Copy to clipboard
Posted by: flytiger
Posted on: 2007-09-20 12:09

greeting[0] assigned value twice, greeting[2] didn't assign anything


   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