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

Thread: I am making a silly mistake but I cant find where! PLEASE HELP!

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question I am making a silly mistake but I cant find where! PLEASE HELP!

    SOLVED

    The error I get is: testings.java:28: ';' expected
    System.out.print(occurs('a',"hello"))


    The code:


    public class testings {

    public static boolean occurs(char c, String s) {
    boolean to_return = false;
    while(true) {
    if(s.equals("")) return to_return;
    // s is not the empty string
    char c2 = s.charAt(0);
    System.out.print("c2 is "+c2);
    System.out.print("c is "+c);
    if(c==c2) { to_return = true; }
    s=s.substring(1);

    return to_return;

    }

    }
    public static void main(String[] args) {
    System.out.print(occurs('a',"hello"))
    }

    }
    Last edited by akmi5; April 13th, 2012 at 03:35 PM. Reason: SOLVED!


  2. #2
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: I am making a silly mistake but I cant find where! PLEASE HELP!

    Quote Originally Posted by akmi5 View Post
    [B]The error I get is: testings.java:28: ';' expected
    System.out.print(occurs('a',"hello"))
    Hello akmi5!
    As your compiler says:
    ';' expected. You have forgotten to put a semicolon(;) after your statement ( System.out.print(occurs('a',"hello")) ).

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    6
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Re: I am making a silly mistake but I cant find where! PLEASE HELP!

    Quote Originally Posted by andreas90 View Post
    Hello akmi5!
    As your compiler says:
    ';' expected. You have forgotten to put a semicolon(;) after your statement ( System.out.print(occurs('a',"hello")) ).


    Thank you so much!!!!

  4. #4
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I am making a silly mistake but I cant find where! PLEASE HELP!

    Hello akmi5!
    As the compiler says that expected
    System.out.println(occurs('a',"hello"));
    In this line you have forgot to put semi colon

Similar Threads

  1. how come this program only loops twice? wheres my mistake?
    By Rainy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 3rd, 2011, 09:49 AM
  2. New to Java I need help with a simple mistake
    By Reynalto in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 2nd, 2010, 04:12 PM
  3. Silly error
    By American in forum Java Theory & Questions
    Replies: 5
    Last Post: August 23rd, 2010, 01:31 PM
  4. Im getting 1 Silly error can someone help please
    By JavaNoob82 in forum What's Wrong With My Code?
    Replies: 14
    Last Post: January 24th, 2010, 06:55 PM
  5. Digital map application with Java GUI
    By donjuan in forum AWT / Java Swing
    Replies: 3
    Last Post: May 15th, 2009, 03:32 AM

Tags for this Thread