Results 1 to 2 of 2

Thread: Strange Error

  1. #1
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Question Strange Error

    Hi. I have been through my program and removed lines that print unneccessary information to the screen.

    I have used these lines of code.

    //declare the char array
    char[] stringArray;
    //convert string into array using toCharArray() method of string class
    stringArray = filename.toCharArray();
    //display the array
    for(int index=0; index < stringArray.length; index++)
    System.out.println(stringArray[index]);
    int check=((stringArray.length)-4);

    And the program compiles perfectly.

    I then took out the line System.out.println(stringArray[index]);
    and then the program would no longer compile.

    I got these error messages.
    savefilepicker.java:102: '.class' expected
    int check=((stringArray.length)-4);
    ^
    savefilepicker.java:102: not a statement
    int check=((stringArray.length)-4);
    ^
    savefilepicker.java:102: illegal start of expression
    int check=((stringArray.length)-4);
    ^
    savefilepicker.java:102: ';' expected
    int check=((stringArray.length)-4);
    ^
    savefilepicker.java:102: not a statement
    int check=((stringArray.length)-4);
    ^
    savefilepicker.java:102: ';' expected
    int check=((stringArray.length)-4);
    ^
    6 errors

    Why has this happened? Is this an error with Java? I don't see why not printing something to the screen would make such a difference!

  2. #2
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Default

    Apologies for last post. I realise what I have done. I should have removed the for line as well.

Similar Threads

  1. Strange Problem
    By Aseem in forum JDBC
    Replies: 5
    Last Post: 02-12-2010, 08:46 AM
  2. Strange, 'Cannot find symbol' error
    By mhouldridge in forum Advanced Java
    Replies: 6
    Last Post: 09-06-2009, 05:54 PM
  3. strange Error message
    By little_polarbear in forum New To Java
    Replies: 4
    Last Post: 08-26-2008, 12:45 AM
  4. System.in.read(); strange error!
    By kantze in forum New To Java
    Replies: 2
    Last Post: 03-19-2008, 02:44 PM
  5. Strange error message "Source not found"
    By ppayal in forum Eclipse
    Replies: 0
    Last Post: 11-25-2007, 07:19 PM

Posting Permissions

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