Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Syntax error on token ";", { expected after this token please HELP

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    3
    My Mood
    Amused
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Syntax error on token ";", { expected after this token please HELP

    import java.io.File;
     
    public class ModDetector{
     
     
     
    	public static class Detect{
    	File folder = new File("c:/");
    	File[] listOfFiles = folder.listFiles();
     
     
    	 for (int i = 0; i < listOfFiles.length; i++) {
    	      if (listOfFiles[i].isFile()) {
    	        System.out.println("File " + listOfFiles[i].getName());
    	      } else if (listOfFiles[i].isDirectory()) {
    	        System.out.println("Directory " + listOfFiles[i].getName());
    	      }
    	    }
    	  }
    	}
    }
    the problem is in 9th row, last token ";" plz help, quick fix no suggestions...


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Syntax error on token ";", { expected after this token please HELP

    Which line is the 9th line?
    You could have added a comment like: //<<<<<<<<<< LINE 9

    Better yet, post the full text of the compiler's error message.

  3. #3
    Member clydefrog's Avatar
    Join Date
    Feb 2012
    Posts
    67
    Thanks
    15
    Thanked 2 Times in 2 Posts

    Default Re: Syntax error on token ";", { expected after this token please HELP

    i believe u have an extra '}'

    i dont know where but i count 5 '{' and 6 '}'

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Syntax error on token ";", { expected after this token please HELP

    You need to put your code within the main method. There is no application start point.

    public static void main(String args[]){
    // code to execute here
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  5. #5
    Junior Member
    Join Date
    Mar 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Syntax error on token ";", { expected after this token please HELP

    I think this is what you intended:
    ...edited by moderator

    You have an extra closing curly brace at the end. Apart from that it seems to me that using a static inner class is probably not what you intend. If it is -- you must create a method inside the inner class which holds the code you want to run. You must then call that method from another part of your program (i.e. the main() method).
    Last edited by rektiphyr; March 1st, 2012 at 03:12 PM. Reason: Correcting SpoonFeeding

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Syntax error on token ";", { expected after this token please HELP

    @rektiphyr, please read the forum rules, as well as the following:
    http://www.javaprogrammingforums.com...n-feeding.html

  7. #7
    Junior Member
    Join Date
    Mar 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Syntax error on token ";", { expected after this token please HELP

    Quote Originally Posted by copeg View Post
    @rektiphyr, please read the forum rules, as well as the following:
    http://www.javaprogrammingforums.com...n-feeding.html
    My appologies -- I have now read and understand the forum rules. I have also edited my original post.

Similar Threads

  1. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  2. Replies: 2
    Last Post: September 23rd, 2011, 07:09 AM
  3. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM
  4. Why the error said "few parameters expected 7" while i only have 6 fields?
    By Hafiz Mughni in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 9th, 2011, 10:45 AM
  5. Syntax error on token ";", @ expected after this token
    By MagicMojo in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 16th, 2011, 07:48 AM

Tags for this Thread