You chose the wrong implementing class, the priority queue, well,
prioritizes some inputs with respect others (in your case uses alphabetic order as priority criterion).
Using, for instance the
LinkedList
implementing class, you could obtain the expected output:
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
public class QS {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
scan.close();
char[] s = input.toCharArray();
LinkedList<Character> queue=new LinkedList<Character>();
Stack<Character> st = new Stack<Character>();
for (char c : s) {
st.push(c);
queue.add(c);
}
System.out.println("STACK .... ");
for(int i =0;i<input.length();i++){
System.out.println(st.pop());
}
System.out.println("QUEUE .... ");
for(int i =0;i<input.length();i++){
System.out.println(queue.poll());
}
}
}