The jist of the program is to create a Stack of Strings to store a list of names and a Queue that stores all the stacks of names.
The problem is I'm getting the
Note: G:\AP Computer Science AB\Chapter 3\Labs\SplahMountain.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Error in the compiler
I know how to fix this error through casting, but I cant seem to find what I did wrong here. Maybe you guys can help. I'd really appreciate it.
import java.util.*; import java.text.*; import java.io.*; public class SplahMountain { public static void main(String[] args) { Queue<String> q = new LinkedList<String>(); Stack<Queue> s = new Stack<Queue>(); Scanner input = new Scanner(System.in); System.out.println("Please enter the number of families: "); int numFam = input.nextInt(); int count = 0; for(int x = 0;x<numFam;x++) { System.out.println("How many in this family?: "); count = input.nextInt(); for(int y = 0;y<count;y++) { System.out.println("Enter a name: "); q.offer(new String(input.nextLine())); } s.push((Queue)q); q = new LinkedList<String>(); } for(int z = 0;z<s.size();z++) { q = s.pop(); for(int w = 0;w<q.size();w++) { System.out.println(q.remove()); } System.out.println(); } } }