Results 1 to 2 of 2
  1. #1
    kiddCOWBOYY is offline javaNOOB
    Join Date
    Mar 2012
    Location
    Texas
    Posts
    16
    Rep Power
    0

    Default 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");
            }
        }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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

  1. <identifier expected> error. please help!
    By christopherx in forum AWT / Swing
    Replies: 9
    Last Post: 10-02-2011, 11:23 PM
  2. identifier expected error
    By Java Learner in forum New To Java
    Replies: 1
    Last Post: 04-27-2010, 09:13 PM
  3. Error:identifier expected(Help!)
    By chhoton in forum New To Java
    Replies: 8
    Last Post: 09-22-2009, 05:42 PM
  4. getting identifier expected error . help me !
    By victorkeath in forum New To Java
    Replies: 3
    Last Post: 11-07-2008, 06:49 PM
  5. Error: <identifier> expected
    By barney in forum AWT / Swing
    Replies: 2
    Last Post: 07-31-2007, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •