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 12 of 12

Thread: I have one error on a 2 simple codes.

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I have one error on a 2 simple codes.

    I have 1 error in both of these. It's an extra credit assignment. This is my first time coding with Java and I don't know what to fix because when I compile it, it says one error and it wont run.

    The First One:

    public static void main(String args[]){ 
    String firstName = "Tim"; 
    String lastName; 
    lastName = "blankityBlankBlank"; 
     
    System.out.println(Tim + "\n\n"); 
    System.out.println(blankityBlankBlank); 
     
    }


    The second one

    public static void main(String args[]){ 
    boolean leapYear = false; 
     
    for(int year = 1900; year <= 2013; year++){ 
    if(year % 400 == 0){ 
    leapYear = true; 
    }else if(year % 100 == 0){ 
    leapYear = false; 
    }else if(year % 4 == 0){ 
    leapYear = true; 
    }else{ 
    leapYear = false; 
    } 
     
    if(leapYear == true){ 
    System.out.println(year + " is a leap year"); 
    } 
     
    } 
    }

    If someone could help me out with these that would be great. Pretty urgent need to send it in tonight.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have one error on a 2 simple codes.

    Please copy the full text of the error message and paste it here. It has important info about the error.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have one error on a 2 simple codes.

    The error for the first one says:

    ----jGRASP exec: javac -g Name.Java
    error: Class names, 'Name.Java', are only accepted if annotation processing is explicitly requested
    1 error

    ----jGRASP wedge: exit code for process is 1.
    ----jGRASP: operation complete

    The error for the second one says:

    ----jGRASP exec: javac -g LeapYear.Java
    error: Class names, 'LeapYear.Java', are only accepted if annotation processing is explicitly requested
    1 error

    ----jGRASP wedge: exit code for process is 1.
    ----jGRASP: operation complete.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have one error on a 2 simple codes.

    Both of the sections of posted code are missing the class definitions.

    Declaring Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have one error on a 2 simple codes.

    I read that and put Class Name { in front of it and put a another bracket at the end and it didn't work. Maybe i'm just missing a step, I'm quite bad at this stuff.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have one error on a 2 simple codes.

    it didn't work
    When you get an error, copy the full text and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have one error on a 2 simple codes.

    Ok I think I've gotten the second one correct.
    The error for the first one is.

    ----jGRASP exec: javac -g Name.java
    Name.java:3: cannot find symbol
    symbol : class string
    location: class Name
    public static void main(string args[]){
    ^
    Name.java:7: cannot find symbol
    symbol : method printnln(java.lang.String)
    location: class java.io.PrintStream
    System.out.printnln(firstName + "\n\n");
    ^
    2 errors

    ----jGRASP wedge: exit code for process is 1.
    ----jGRASP: operation complete.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have one error on a 2 simple codes.

    Java is case sensitive. Make sure the names of the classes are spelled correctly. Compare the one that works with the one that doesn't. Also the ^ will point near the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have one error on a 2 simple codes.

    I've fixed some of the stuff and have this right now

    public class Name
    {
    public static void main(String args[]){
    String firstName = "Tim";
    String lastName;
    lastName = "Kleinknecht";
    Systemoutprintnln(firstName + "\n\n");
    Systemoutprintln(lastName);
     
    }
    }

    and am getting the error

    ----jGRASP exec: javac -g Name.java
    Name.java:7: cannot find symbol
    symbol : method Systemoutprintnln(java.lang.String)
    location: class Name
    Systemoutprintnln(firstName + "\n\n");
    ^
    Name.java:8: cannot find symbol
    symbol : method Systemoutprintln(java.lang.String)
    location: class Name
    Systemoutprintln(lastName);
    ^
    2 errors

    ----jGRASP wedge: exit code for process is 1.
    ----jGRASP: operation complete.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have one error on a 2 simple codes.

    take a look at what I wrote originally at the top
    Not sure what I'm supposed to look for in the first post.
    The code has compiler errors that need to be fixed. I gave a hint in my last post: Check the spelling.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have one error on a 2 simple codes.

    NEVERMIND I FINALLY GOT IT!
    Thanks so much for your help, it's gonna boost my grade up 5%!

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: I have one error on a 2 simple codes.

    Glad you got it working.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Error codes trying to run a batch file
    By any-mgzt in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 3rd, 2013, 07:18 AM
  2. Help with this very simple error
    By Tctwins in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 21st, 2012, 01:54 PM
  3. Simple I/O Java Error
    By Prox in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 25th, 2011, 04:48 PM
  4. Error for a simple array
    By DudeJericho in forum Collections and Generics
    Replies: 4
    Last Post: April 25th, 2011, 02:46 PM
  5. Has to be a simple error, but I can't find it.
    By fride360 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 22nd, 2011, 10:15 AM