I'm practicing Java and I have a question about printing all values inside a String array. I would need to print everything inside the String arrays I have created.
I can't seem to make "Arrays.toString" to work in my code and I don't want to have to point out each value inside the array. Is there a way I can print them all at once?
public class MyCode {
public static void main(String[] args) {
String[] majority = {"Congrats, you may enter!", " Awesome!"};
String[] minority = {"I'm sorry, you are too young.", " Ah that's too bad!"};
int permition = 17;
boolean authorization = (permition >= 18);
if (authorization == true) {
System.out.println(majority[0] + majority[1]);
} else {
System.out.println(minority[0] + minority[1]);
}
}
}
So, if the person is above or equal to 18, the result should be "Congrats, you may enter! Awesome!", or if below 18 "I'm sorry, you are too young. Ah that's too bad!".