Compilation Error

I submitted my code written in java and recived the following errors. what may be the possible reason for that;

“Main.java:6: cannot find symbol
symbol : class Set
location: class Main
Set s=new TreeSet();
^
Main.java:6: cannot find symbol
symbol : class TreeSet
location: class Main
Set s=new TreeSet();
^
Main.java:7: cannot find symbol
symbol : class Scanner
location: class Main
Scanner s1=new Scanner(System.in);
^
Main.java:7: cannot find symbol
symbol : class Scanner
location: class Main
Scanner s1=new Scanner(System.in);
^
Main.java:20: cannot find symbol
symbol : class Iterator
location: class Main
Iterator i=s.iterator();
^”

give me link to your code…

@shivam217
http://www.codechef.com/viewsolution/4341745
this is the link to the code

In the future I would (1) make your question/error more readable and (2) actually include the code or a link to the submission with the error.

I can think of two possible answers:

(1) You didn’t import java.util.TreeSet; java.util.Scanner; etc. (or simply import java.util.*)

(2) Or you could be referring to a variable or object that isn’t visible in the method trying to access it. Ex:

public class ATM2{
public static void main(String[] args){
	int n = 10;
	print();
}
public static void print(){
	System.out.println(n);
}

}

Will not run because print() cannot access ‘n’

import java.util.*; and your problem is solved

@d_stallion as told by @gage import java.util* and remove public from the class and one thing no need to store the numbers in Treeset, just print the numbers after the conditon is checked (means if numbers is not equal to 42 , just print it otherwise break from the loop). link to accepted solution … Happy Coding :slight_smile:

thank you guys for helping me out…i will take care of your suggestions in the future…thank again

//