This is probably a simple fix, but I am just not seeing it. I am trying to figure out, how do I get my printOut() method to print properly from the main Project5PartA? Do I need get, set, and return methods? Also, is my while loop even necessary in the Tester class?
The program compiles and keeps running to infinity, so I guess the while loop is wrong. But it also only prints out [Ljava.lang.String;@7c1c8c58 continuously on each line.
The classes that extend the main are irrelevant and part of the project. Apologies if this was posted wrong and thanks for any help.
The output of the whole program would be similar to:
Bark, bark.
Meow, meow.
Roooaaar.
Dog says woof, woof.
Cat says meow, meow.
Tester Class:
public class Tester {
String[] animalArray = {"Dog", "Cat", "tRex", "Cow", "Pig", "Snake",
"Goat", "Owl", "Chicken", "Frog"};
String[] noiseArray = {"Woof, woof", "Meow, meow", "Roooaaar", "Mooo",
"Oink, oink", "Hissss", "Baaa", "Hoot, hoot", "Bock, bock",
"Ribbit, ribbit"};
String[] printArray = new String[10];
public String printOut() {
while (true) {
for (int i = 0; i < 10; i++) {
String value = (animalArray[i] + " says " + noiseArray[i] + ".");
printArray[i] = value;
System.out.println();
System.out.println(printArray);
break;
}
}
}
}