Write a valid Java statement to store the gender of 5 people as 'M' or 'F' in an array
Answers
Answered by
1
Answer:
public class Main {
public static void main(String[] args) {
char[] gender= new char[5];
gender[0] = 'M'; gender[1] = 'M'; gender[2] = 'F'; gender[3] = 'F';
gender[4] = 'M';
}
}
Explanation:
First I created a char array to store the gender.
Next I populated the array with genders 'M' or 'F'.
Similar questions
English,
2 months ago
English,
2 months ago
Computer Science,
5 months ago
Science,
11 months ago
Physics,
11 months ago