package com.codegym.task.task07.task0714;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
/*
Words in reverse
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<String>();
for(int i = 0; i < 5; i ++) {
list.add(reader.readLine());
}
list.remove(2);
for(int i = 3; i > -1; i --) {
System.out.println(list.get(i));
}
}
}
what's wrong with it?
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Charlie Branson
10 February 2020, 19:03
you can put it into reverse order by designating it in list.add(0, reader.readLine); then just remove from the list and print it. with your for statement without the reversal. worked perfectly for me.
0
Erik Altink
8 September 2019, 10:19
You should probably use
to reverse the list. 0
Hoang Khai
19 July 2019, 20:26
replace int i=3 with int i=2(the last index)
0
Azja
5 June 2019, 18:39
try change this
to this:
It is same but some test may don't accept that +4