Home Java Java-get-example Java error cannot find symbol
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Java error cannot find symbol

Advertisement
The java error cannot find symbol occurred when a Compiler does not recognize a class name.

Java error cannot find symbol

     

The java error cannot find symbol occurred when a Compiler does not recognize a class name. The following are the reason for such an error  -

1)When a programmer misspelled the name of the class.

2When a programmer do not Imported the class name.

In this Tutorial we want to describe you a code that help you in understanding java error cannot made symbol. For this we have a class name 'cannot find symbol'. Inside the main method we have initialized a int variable a and b with respective values and store the sum of the value in variable int d.The System.out.println. is used to print the output  in variable d in the try block. But in this code the programmer misspelled the variable.,inspite  of writing d,the programmer write variable e,The catch block helps you in handling the error occurred in the try block. Therefore  the compiler does not recognize a variable e show you an error Java error cannot find symbol.

Cannotfindsymbol.java
import java.lang.*;
public class Cannotfindsymbol {

  
  public static void main(String[] args) {
 try{
  int a=10;
 int b=3;
 
 int d=a+b;
 System.out.println(e);
  }
  catch(Exception ex){
  System.out.println(ex);
  }
  }
}

Output
/home/girish/NetBeansProjects/errors/src/
Cannotfindsymbol.java:
11: cannot find symbol

symbol  : variable e
location: class Cannotfindsymbol
  System.out.println(e);
error0

To remove this error you have to declare the variable e.

Download code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 3, 2008

Related Tutorials

Ask Questions?    Discuss: Java error cannot find symbol   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
sadegh
July 1, 2011
tutorial

iam a begginer.please help me .i want to do make a simple calculature in j2me.thanks.
Faris
August 18, 2011
Error: cannot find

Please help me find this error. INPUT: import javax.swing.JOptionPane; class CounterControlledLoop { public static void main ( String[] args ) { String numberStr; double number; char total = 0; int i = 0; final int N = 5; while ( i < N ) { numberStr = JOptionPane.showInputDialog( "Enter a number: "); number = Double.parseDouble( numberStr ); total += number; i++; } JOptionpane.showMessageDialog( "The total is" + total ); System.exit(0); } } OUTPUT: JOptionpane.showMessageDialog( "The total is" + total ); ^ symbol: variable JOptionpane location: class CounterControlledLoop 1 error
jose
September 11, 2011
error canont

--------------------Configuration: <Default>-------------------- C:\Users\JHOSEP\Desktop\Nueva carpeta\MenuFracciones.java:9: error: cannot find symbol f1 = new Fraccionario(); este es mi error espero me ayuden
sandhya rani nayak
October 20, 2011
java errors

need explanation on seberal java errors
sumit
November 1, 2011
java errors

i have written every thing correctly but can not run a.start()..............please help
Alexey
January 21, 2012
+

3. When programmer didn't declare variable (didn't put "Int, String, Float, etc.")
Neil
May 27, 2012
Still confused about missing symbol

Hello, there. I'm a programming student and while I understand the idea of not finding a symbol, I'm still in need of assistance for my following code: public class FileTicketAsText { private static String file; /** * @param args the command line arguments */ public static void Main(String[] args) { // TODO code application logic here Scanner scan = new Scanner(System.in); String name = getName(scan, " Name"); String symbol = getSymbol(scan, " Symbol "); String title = getTitle(scan, "Title"); String summary = getSummary(scan, " Summary "); String question = getQuestion(scan, " Question"); String answer = getAnswer(scan, " Answer"); String nameFile = file + "txt"; FileWriter outputStream = null; String word = null; try { outputStream = new FileWriter(nameFile); BufferedWriter out = new BufferedWriter(outputStream); out.write(word + "/n"); out.close(); } catch (IOException ex){ Logger.getLogger(Main.class.getName().log(Level.SEVERE,null,ex)); } } private static String getName(Scanner scan, String string) { System.out.print(string + "?"); return scan.nextLine(); } private static String getSymbol(Scanner scan, String string) { System.out.print(string + "?"); return scan.nextLine(); } private static String getSummary(Scanner scan, String string) { System.out.print(string + "?"); return scan.nextLine(); } private static String getQuestion(Scanner scan, String string) { System.out.print(string + "?"); return scan.nextLine(); } private static String getAnswer(Scanner scan, String string) { System.out.println(string + "?"); return scan.nextLine(); } private static String getTitle(Scanner scan, String string) { System.out.print(string + "?"); return scan.nextLine(); } } Specifically, the "Logger.getLogger(Main.class.getName().log(Level.SEVERE,null,ex)); " is giving me trouble, because I cannot find the symbol and such my JDK(NetBeans) is giving me all these imports which I don't understand and don't work. All in all, I am in need for some help
Leo
September 2, 2012
cannot find symbol

I have this problem with the cannot find symbol. This is my code. public class KineticEnergy { public static void main(String[] args) { KeyboardReader input = new KeyboardReader(); System.out.println("Enter the mass of the object"); double mass = input. readDouble(); System.out.println("Enter the volume of the object"); double volume = input. readDouble(); System.out.println("Mass =" + mass); System.out.println("Volume =" + volume); double KE = 1.0/2 * mass * volume * volume; System.out.println("Kenetic Energy =" + KE); } } Then when i try to compile it says that cannot find symbol in KeyboardReader.Please help
Abinaya
October 10, 2012
cannot find symbol error

import java.io.*; public class FisherPriceToys { String ToyName,Colour; double Cost; int YearOfManufacture; FisherPriceToys(String a,String b,double c,int d) { ToyName=a; Colour=b; Cost=c; YearOfManufacture=d; } public static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the toy's name of 20 characters"); String x=in.readLine(); int y=x.length(); for(;y==20;) { System.out.println("Invalid choice.Enter the toy's name of 20 characters"); String z=in.readLine(); y=z.length(); } System.out.println("Enter the toy's colour of 15 characters"); String m=in.readLine(); int n=m.length(); for(;n==15;) { System.out.println("Invalid choice.Enter the toy's colour of 15 characters"); String p=in.readLine(); n=p.length(); } System.out.println("Enter the toy's cost"); String cost=in.readLine(); double cos=Double.parseDouble(cost); System.out.println("Enter the Year of manufacture"); String year=in.readLine(); int ye=Integer.parseInt(year); int k=ye,g=0; do { k=k/10; g++; } while(k!=0); for(;g==4;) { System.out.println("Invalid choice.Enter the valid year"); String yer=in.readLine(); int years=Integer.parseInt(yer); k=years; do { k=k/10; g++; } while(k!=0); } FisherPriceToys ob=new FisherPriceToys(z,p,cos,years); System.out.println("Toy's name is "+ob.ToyName); System.out.println("Toy's colour is "+ob.Colour); System.out.println("Toy's cost is "+ob.Cost); System.out.println("Toy's year of manufacture is "+ob.YearOfManufacture); } } /**while compling this program error is reported on constructor calling.Please send the solution to my email.
Abinaya
October 10, 2012
error cannot find symbol

import java.io.*; public class FisherPriceToys { String ToyName,Colour; double Cost; int YearOfManufacture; FisherPriceToys(String a,String b,double c,int d) { ToyName=a; Colour=b; Cost=c; YearOfManufacture=d; } public static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the toy's name of 20 characters"); String x=in.readLine(); int y=x.length(); for(;y==20;) { System.out.println("Invalid choice.Enter the toy's name of 20 characters"); String z=in.readLine(); y=z.length(); } System.out.println("Enter the toy's colour of 15 characters"); String m=in.readLine(); int n=m.length(); for(;n==15;) { System.out.println("Invalid choice.Enter the toy's colour of 15 characters"); String p=in.readLine(); n=p.length(); } System.out.println("Enter the toy's cost"); String cost=in.readLine(); double cos=Double.parseDouble(cost); System.out.println("Enter the Year of manufacture"); String year=in.readLine(); int ye=Integer.parseInt(year); int k=ye,g=0; do { k=k/10; g++; } while(k!=0); for(;g==4;) { System.out.println("Invalid choice.Enter the valid year"); String yer=in.readLine(); int years=Integer.parseInt(yer); k=years; do { k=k/10; g++; } while(k!=0); } FisherPriceToys ob=new FisherPriceToys(z,p,cos,years); System.out.println("Toy's name is "+ob.ToyName); System.out.println("Toy's colour is "+ob.Colour); System.out.println("Toy's cost is "+ob.Cost); System.out.println("Toy's year of manufacture is "+ob.YearOfManufacture); } } /**error is reported every time i compile this program on calling the constructor.please send the solution to my email provided.
ln mahapatra
January 7, 2013
j2ee

find cant find symbol error while executing a servlet program after import package for classes
DMCA.com