I got this to work when just using integers but now I have to use strings and I am completely stumped.
I tried putting a whole array in and hoping it will print the words out backwards for a start but that didnt work either because it take whatever part of the array I put in and prints that word out. I also need it to print out the word's characters backwards and not just the sentence. This is my first post Im sorry if i'm not following all the rules i'm trying to. Thanks.
I tried putting a whole array in and hoping it will print the words out backwards for a start but that didnt work either because it take whatever part of the array I put in and prints that word out. I also need it to print out the word's characters backwards and not just the sentence. This is my first post Im sorry if i'm not following all the rules i'm trying to. Thanks.
import java.util.Stack;
public class ReverseSentence
{
public static void main(String args[])
{
Stack lifo = new Stack();
String array[] = {"hello", "how", "are", "you"};
{
lifo.push ( new String(array[1]) );
}
while ( !lifo.empty() )
{
System.out.println(lifo);
lifo.pop();
}
}
}