Ok, so the assignment is that I take the Lisp expression:
'(A B C D)
And turn it into
'(D C B A)
in Java. To do this, I have this code:
String[] items = input.split(" |\\(|\\)|'");
int y = 0;
for (String x : items){ //this part is purely for debugging
System.out.println(y + " " + x);
y++;
}
So that it splits it by a space, (, ), and '. The output I should be getting is
0 A
1 B
2 C
3 D
But for some reason, The output I get is
0
1
2 A
3 B
4 C
5 D
Why does this happen? Also, does anyone has a suggestion for a better way of doing this?