Results 1 to 13 of 13
  1. #1
    Sean_J is offline Member
    Join Date
    Feb 2010
    Posts
    16
    Rep Power
    0

    Default error message assistance

    can someone tell me how to solve the error message that gets presented to me when i try to compile this. I am new to this so please be a little nice.
    Java Code:
    public class Lesson5 //seanj My Double
    {
      public static void main(String args[])
      {
    char c;
    for (int j = 97; j <= 122; j++) {
             c = (char) (j 32);
             System.out.print(c);
      }
    }
    File: C:\Users\SeanJJ\Tester.java [line: 7]
    Error: C:\Users\SeanJJ\Tester.java:7: illegal character: \8211
    File: C:\Users\SeanJJ\Tester.java [line: 7]
    Error: C:\Users\SeanJJ\Tester.java:7: not a statement
    File: C:\Users\SeanJJ\Tester.java [line: 7]
    Error: C:\Users\SeanJJ\Tester.java:7: ';' expected
    File: C:\Users\SeanJJ\Tester.java [line: 10]
    Error: C:\Users\SeanJJ\Tester.java:10: reached end of file while parsing

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,763
    Blog Entries
    7
    Rep Power
    21

    Default

    You seem to have a character (8211) in your source code that the compiler doesn't like; copying and pasting your code here got rid of that character (at least the forum software can't display it). Try to type in the source code again manually and see what happens when you try to compile it.

    kind regards,

    Jos

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Did you copied that code from the web into your file? Sometimes CSS characters rendered in unrecognized way by the compiler.

    C:\Users\SeanJJ\Tester.java [line: 7]
    Check on line 7, you can find what's it.

  4. #4
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Also, you should have
    Java Code:
            public static void main(String[] args)
    and not
    Java Code:
            public static void main(String args[])
    -Gary-

  5. #5
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    307
    Rep Power
    6

    Default

    You also seem to be missing a close brace '}'

  6. #6
    Sean_J is offline Member
    Join Date
    Feb 2010
    Posts
    16
    Rep Power
    0

    Default

    Thanks for the reply, i fixed these things and they compiled correctly. And i got the solution to the problem, guess i wont be copy and pasting things anymore.

  7. #7
    Sean_J is offline Member
    Join Date
    Feb 2010
    Posts
    16
    Rep Power
    0

    Default

    Here is the finished fixed version.
    Java Code:
    public class Test
    {
      public static void main(
    )
      {
        String s = "Alfred E. Numan";
        char ch;
        for (int x=0;x<s.length();x++){
          ch=s.charAt(x);
          { if((ch<=90)&&(ch>=65))
            ch=(char)(ch+32);
          System.out.print(ch);
          }
       }
      }
    }
    Compilation completed.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Following is the normal indentation people use in coding with Java. I just re-write your code segment for your consideration.

    Java Code:
    public class Test {
        public static void main() {
            String s = "Alfred E. Numan";
            char ch;
            for (int x = 0; x < s.length(); x++) {
                ch = s.charAt(x);
                {
                    if ((ch <= 90) && (ch >= 65)) {
                        ch = (char) (ch + 32);
                    }
                    System.out.print(ch);
                }
            }
        }
    }

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Even for a single code body like in if loop and so on, it's better to cover with parenthesis. Then it's easy to read your code for others, and for you as well in later day. Happy coding. :)

  10. #10
    Sean_J is offline Member
    Join Date
    Feb 2010
    Posts
    16
    Rep Power
    0

    Default

    Thanks m8 :)

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    You are welcome. :)

    If you solve the problem, then please mark the thread solved from Thread Tools menu on top of the thread.

  12. #12
    Sean_J is offline Member
    Join Date
    Feb 2010
    Posts
    16
    Rep Power
    0

    Default

    Still new to the forum thanks for letting me know :) have a good day.

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Error assistance
    By bobbychiken in forum New To Java
    Replies: 2
    Last Post: 11-21-2009, 11:54 PM
  2. Error Message????
    By Cubba27 in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 03:46 PM
  3. Error Message in JBuilder
    By RavenNevarmore in forum New To Java
    Replies: 4
    Last Post: 10-08-2008, 07:53 AM
  4. java error message
    By baileyr in forum New To Java
    Replies: 2
    Last Post: 01-23-2008, 04:47 AM
  5. error message on jsp
    By sandor in forum Web Frameworks
    Replies: 1
    Last Post: 04-11-2007, 03:10 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
  •