Results 1 to 8 of 8
  1. #1
    yairku is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Exclamation The constructor Bucket(int) is undefined

    Hello
    I am trying to practice Java, I have a test on Wednesday.
    When I try to write this:
    Bucket[] arr= new Bucket[6];
    arr [0]= new Bucket(6);

    The underlined text, new Bucket(6) is underlined in red, and the reason is: "The constructor Bucket(int) is undefined".
    The class Bucket has no problems in its constructor, and it is imported to my class correctly.
    The constructor of the Bucket class,
    public Bucket (int capacity)
    {
    this.capacity = capacity;
    this.currentAmount = 0;
    }

    requires only one int operator.
    So what is the problem??
    Please help me soon!!
    Yairku

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

    Default

    Quote Originally Posted by yairku View Post
    Hello
    I am trying to practice Java, I have a test on Wednesday.
    When I try to write this:
    Bucket[] arr= new Bucket[6];
    arr [0]= new Bucket(6);

    The underlined text, new Bucket(6) is underlined in red, and the reason is: "The constructor Bucket(int) is undefined".
    The class Bucket has no problems in its constructor, and it is imported to my class correctly.
    The constructor of the Bucket class,
    public Bucket (int capacity)
    {
    this.capacity = capacity;
    this.currentAmount = 0;
    }

    requires only one int operator.
    So what is the problem??
    The compiler doesn't lie: it really can't find a constructor Bucket(int); post more of your code if necessary.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    yairku is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    Okay, it can't find a constructor Bucket(int);
    Why that occurs and what should I do in order to fix it?
    Thanks

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

    Default

    Quote Originally Posted by yairku View Post
    Okay, it can't find a constructor Bucket(int);
    Why that occurs and what should I do in order to fix it?
    Thanks
    Which contructors are implemented in that Bucket class? And why did you say in your original post that the constructor Bucket(int) was defined? (you even showed us a possible implementation).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    yairku is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    The problem has been solved!
    I don't know why, but I had to write Bucket(int, String), although it is not written in the Bucket class.
    Thank you very much for trying to help,
    Yair

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    As Jos has asked, you'll need to show us the code.

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

    Default

    Quote Originally Posted by Tolls View Post
    As Jos has asked, you'll need to show us the code.
    I think this is one of those threads that mysteriously comes to a happy end; oh well ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    yairku is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    I think this is one of those threads that mysteriously comes to a happy end; oh well ...
    I'm sure this is one of those threads...
    I had to insert a string name for the bucket, because this class is graphic.
    If I had read the whole question and not only what I should do, I would not open this thread.
    Thank you,
    Yair

Similar Threads

  1. bucket sort, list in java
    By someone in forum New To Java
    Replies: 10
    Last Post: 04-12-2011, 12:13 AM
  2. problem with my bucket sort
    By someone in forum New To Java
    Replies: 8
    Last Post: 04-12-2011, 12:09 AM
  3. Undefined attribute name
    By Dieter in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-03-2010, 11:44 AM
  4. Replies: 7
    Last Post: 11-03-2009, 03:18 AM
  5. Replies: 1
    Last Post: 08-01-2007, 09:55 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
  •