这是源代码的相关位:
class Dice
{
String name ;
int x ;
int[] sum ;
Run Code Online (Sandbox Code Playgroud)
...
public Dice (String name)
{
this.name = name ;
this.x = 0 ;
this.sum = new int[7] ;
}
Run Code Online (Sandbox Code Playgroud)
...
public static void main (String[] arg)
{
Dice a1 = new Dice ("a1") ;
printValues (a1) ;
}
public static void printDice (Dice Dice)
{
System.out.println (Dice.name) ;
System.out.println ("value: "+Dice.x) ;
printValues (Dice) ;
}
public static void printValues (Dice Dice)
{
for (int i = 0; i<Dice.sum.length; i++)
System.out.println ("#of "+i+"'s: "+Dice.sum[i]) ;
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
#of 0's: 0
#of 1's: 0
#of 2's: 0
#of 3's: 0
#of 4's: 0
#of 5's: 0
#of 6's: 0
Run Code Online (Sandbox Code Playgroud)
为什么这两行不在里面执行printDice:
System.out.println (Dice.name) ;
System.out.println ("value: "+Dice.x) ;
Run Code Online (Sandbox Code Playgroud)
如果他们的话,我希望能看到"A1"和"价值:0"的行的顶部打印#of的
| 归档时间: |
|
| 查看次数: |
601 次 |
| 最近记录: |