- #1
iamjon.smith
- 117
- 3
Ok, I have a java app that allows you to choose a class (wizard/elf) and is supposed to give a random amount of health (an array with 10 values) and 25 points of health. When I run the program it gives me the memory location from the array and not the value. I know I am missing something simple, but can't figure it out. Please help!
OUTPUT:
Welcome to the Video Game Character Applcation
Enter customer type (Wizard/Elf): wizard
You have chosen: wizard
Enter your Character's Name:
Character Type: wizard
Health: [Ljava.lang.String;@4c56291a
Gold Amount: 25.0
Continue? (y/n):
PROBLEM IS IN RED. PLEASE ADVISE :D
Code:
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Welcome to the Video Game Character Applcation");
Scanner sc = new Scanner(System.in);
String choice = "y";
while (!choice.equalsIgnoreCase("n"))
{
// get the input from the user
// System.out.print("Enter customer type (r/c): ");
String characterType = Validator.getString(sc,
"Enter customer type (Wizard/Elf): ");
//String characterType = getValidCharacterType(sc, "Enter customer type (Wizard/Elf): "); // TODO code application logic here
System.out.println("You have chosen: "+ characterType);
System.out.println("Enter your Character's Name: ");
String[] charhealth = new String[10];
charhealth[0] = "1";
charhealth[1] = "2";
charhealth[2] = "3";
charhealth[3] = "4";
charhealth[4] = "5";
charhealth[5] = "6";
charhealth[6] = "7";
charhealth[7] = "8";
charhealth[8] = "9";
charhealth[9] = "10";
for (int i = 10; i < charhealth.length; i = i++) {
System.out.print("Health: " + charhealth[i]);
}
OUTPUT:
Welcome to the Video Game Character Applcation
Enter customer type (Wizard/Elf): wizard
You have chosen: wizard
Enter your Character's Name:
Character Type: wizard
Health: [Ljava.lang.String;@4c56291a
Gold Amount: 25.0
Continue? (y/n):
PROBLEM IS IN RED. PLEASE ADVISE :D