Results 1 to 4 of 4

Thread: error

  1. #1
    jot321 is offline Member
    Join Date
    Sep 2008
    Posts
    13
    Rep Power
    0

    Default error

    class constructor
    {
    constructor(int a,int b)
    {
    int a1,b1;
    a1=a;
    b1=b;
    }

    int abc()
    {
    return a1*b1;
    }
    }

    /*error is there that cannot find a1 variable in abc method*/

  2. #2
    jot321 is offline Member
    Join Date
    Sep 2008
    Posts
    13
    Rep Power
    0

    Default

    please reply fast
    its pretty urgent

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    please reply fast
    its pretty urgent
    You would be wise not to state this in your posts. Even if it is urgent to you, realize that it is not urgent to us. Many here take offense to this as it implies to them that a) the poster thinks that his post is more important than everyone else's, and b) that the poster wants to put pressure on the volunteers who come here to help on their own free time. Just a friendly word of advice.

    You need to fix your variable scope. a1 and b1 are only visible in the constructor and are not visible to any other methods of the class. By the way, please rename this class as "constructor" is a terribly confusing name. Also class names should begin with a capital letter. Good luck.

  4. #4
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Java Code:
    class Constructor
    {
    int a1,b1;
    Constructor(int a,int b)
    {
    
    a1=a;
    b1=b;
    }
    
    int abc()
    {
    return a1*b1;
    }
    }

Similar Threads

  1. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 04:28 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
  •