Results 1 to 2 of 2
- 03-23-2012, 12:22 AM #1
javaNOOB
- Join Date
- Mar 2012
- Location
- Texas
- Posts
- 16
- Rep Power
- 0
help on this Identifier error.????
i dont understand whats wrong. please help.
this
is the error
C:\Users\Damien Breaux\Documents\Programing\searchWord.java:39: error: <identifier> expected
catch(Exception ) {}
Java Code:import java.util.Scanner; import java.io.*; public class SearchWord{ public static void main(String[]args)throws IOException { int times=0,count=0,x=0,no=0; Scanner Input =new Scanner(System.in); String filename = keybroad.nextLine(); System.out.println("Enter the sentence:"); File name = outputFile.nextLine(); String word = inputFile.nextLine(); System.out.println("Enter the word:"); try{ for(int i=0;i<s.length();i++) if(w.charAt(0)==s.charAt(i)) { for(int j=0;j<w.length();j++,i++) { if(s.charAt(i)==w.charAt(j)) { count=count+1;} if(count==w.length()) {no=no+1;count=0;}; } } } catch(Exception ) {} if(no==0) { System.out.println("word is not present"); } else { System.out.println("word is present "+no+" times"); } } }
-
Re: help on this Identifier error.????
Your Exception block is missing the Exception variable name and so the compiler is complaining. Any tutorial on Exceptions will show you simple examples of how to do this, and I suggest you have a look. More importantly, your exception block is empty -- you should almost *never* do this. Again, read the tutorials.
Similar Threads
-
<identifier expected> error. please help!
By christopherx in forum AWT / SwingReplies: 9Last Post: 10-02-2011, 10:23 PM -
identifier expected error
By Java Learner in forum New To JavaReplies: 1Last Post: 04-27-2010, 08:13 PM -
Error:identifier expected(Help!)
By chhoton in forum New To JavaReplies: 8Last Post: 09-22-2009, 04:42 PM -
getting identifier expected error . help me !
By victorkeath in forum New To JavaReplies: 3Last Post: 11-07-2008, 05:49 PM -
Error: <identifier> expected
By barney in forum AWT / SwingReplies: 2Last Post: 07-31-2007, 07:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks