希望有人可以帮助我,我是 Java 的菜鸟。我的问题是,当我打印数组时,我得到了一些字符,我想打印数组中的点数。(请忽略不相关的代码,我什至还没有完成)
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
public class MainClass {
public static void main (String[] args){
int arrayIntC, arrayIntE, nOC, nOE;
char confirmNumbers;
do{
String numberOfCharacters = JOptionPane.showInputDialog("Enter the number of characters:");
String numberOfEnemies = JOptionPane.showInputDialog("Enter the number of enemies:");
nOC = Integer.parseInt(numberOfCharacters);
nOE = Integer.parseInt(numberOfEnemies);
JOptionPane.showMessageDialog(null, "Number of characters: " + nOC, "DnD Organizer", JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "Number of enemies: " + nOE, "DnD Organizer", JOptionPane.PLAIN_MESSAGE);
confirmNumbers = JOptionPane.showInputDialog("Are the numbers correct? (y/n)").charAt(0);
}while(confirmNumbers != 'y');
JOptionPane.showMessageDialog(null, "Banarne", "DnD Organizer", JOptionPane.PLAIN_MESSAGE);
arrayIntC = nOC -1;
arrayIntE = nOC -1;
int[] arrayC = {arrayIntC}, arrayE = {arrayIntE};
JOptionPane.showMessageDialog(null, "Platser i arrayC: ", "DnD Organizer", JOptionPane.PLAIN_MESSAGE);
/*for (int i = 0; i <arrayC.length; i++){
System.out.printf("%5d%8d", i, arrayC[i]);
}*/
JOptionPane.showMessageDialog( null, arrayC );
System.exit(0);
}//main
}//MainClass