Recompile with -Xlint problem, I've been able to fix it in the past but this time is difficult
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.
Code :
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();
}
}
}
Re: Recompile with -Xlint problem, I've been able to fix it in the past but this time is difficult
Quote:
Recompile with -Xlint:unchecked for details.
What did the details say?
Re: Recompile with -Xlint problem, I've been able to fix it in the past but this time is difficult
I'm not sure. I don't even know where you would find those.
Re: Recompile with -Xlint problem, I've been able to fix it in the past but this time is difficult
I've actually resolved the issue, the program gave me that error, but ran anyway. Thanks for trying anyway
Re: Recompile with -Xlint problem, I've been able to fix it in the past but this time is difficult
Quote:
Originally Posted by
lukestarchief
I've actually resolved the issue, the program gave me that error, but ran anyway. Thanks for trying anyway
It looks like a warning more than an error. Programs with errors do not compile. You shouldn't ignore warnings either. Treat them like errors even though you can compile and run anyway. Get back in there and fix it. It is not quitting time yet.