** don\'t send the answer in a picture, I need it A text- the subject in JAVA**W
ID: 3718048 • Letter: #
Question
** don't send the answer in a picture, I need it A text- the subject in JAVA**Write the code needed to print all strings that start with the character ‘A’. Write the code if: 1. The strings are stored in an array list; use any proper name for the array list, and assume that it is already created and filled with the strings. 2. The strings are stored in an array; use any proper name for the array, and assume that it is already created and filled with the strings. Note: for each part, write a for loop.
Explanation / Answer
1. The strings are stored in an array list; use any proper name for the array list, and assume that it is already created and filled with the strings.
Answer:
for(String s: list) {
if(s.startsWith("A")) {
System.out.println(s);
}
}
2. The strings are stored in an array; use any proper name for the array, and assume that it is already created and filled with the strings. Note: for each part, write a for loop.
Answer:
for(int i=0;i<list.size();i++) {
String s = list.get(i);
if(s.startsWith("A")) {
System.out.println(s);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.