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

Thread: Guess the error in the code

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

    Default Guess the error in the code

    Hi, my name is Alex,
    and I have to find and correct the errors in this piece of code

    abstract class A { int a,r;
    A(int n, int a) { if (n==0) r=1;
    else if(n==1) r=a;
    else { this(n-1,a); r=r*a; }
    System.out.println(r);
    }
    public static main(String Args[]) { A obiect=new A(10,2); }
    }

    i can't do it
    any help ?


  2. #2
    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: Guess the error in the code

    i can't do it
    Sure you can. What are the errors? Are they compiler errors? Runtime errors?

  3. #3
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: Guess the error in the code

    ill give you a hint...there is an obvious error in your main method

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Guess the error in the code

    @derekxec Thank you for offering assistance on the forum but please beware of those who post homework questions to get quick answers. Please refer to The problem with spoonfeeding if you have any questions.

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Guess the error in the code

    --Edited Post--
    @garymar2013 Please also see the link in post #4
    Last edited by jps; June 10th, 2013 at 09:06 PM. Reason: spoonfeeding removed

Similar Threads

  1. Method error for checking and updating guess in a basic hangman game
    By lotusmind in forum What's Wrong With My Code?
    Replies: 12
    Last Post: April 13th, 2013, 10:03 PM
  2. Word Guess program with a Null Pointer Exception
    By Wallatrix in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 11th, 2013, 02:42 AM
  3. Please help to understand whats the wrong with my guess. - Simple program
    By rayan2004 in forum Object Oriented Programming
    Replies: 1
    Last Post: December 14th, 2012, 01:03 AM
  4. Help with 3 guess Dice game
    By tabmanmatt in forum Loops & Control Statements
    Replies: 1
    Last Post: November 28th, 2012, 07:42 PM
  5. Guess Number (Frame & btnHandler)!!!! HELP
    By xplox2011 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 6th, 2011, 04:08 AM