Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By droidus

Thread: parameters for constructors

  1. #1
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default parameters for constructors

    how would you create a constructor with an unknown amount of parameters?

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

    Default Re: parameters for constructors

    Quote Originally Posted by droidus View Post
    how would you create a constructor with an unknown amount of parameters?
    Can you guess one possible way to do this? Give it a try -- you've nothing to lose and everything to gain.

  3. #3
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: parameters for constructors

    maybe create an array with the values?
    Fubarable likes this.

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

    Default Re: parameters for constructors

    Quote Originally Posted by droidus View Post
    maybe create an array with the values?
    There you go! Good show!

  5. #5
    droidus is offline Senior Member
    Join Date
    Feb 2011
    Posts
    244
    Rep Power
    4

    Default Re: parameters for constructors

    So let's say that I am inputting a list of characters... would I use a for loop in my constructor? and would i leave the parameter list empty?

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

    Default Re: parameters for constructors

    Quote Originally Posted by droidus View Post
    So let's say that I am inputting a list of characters... would I use a for loop in my constructor? and would i leave the parameter list empty?
    Better then discussing it here -- try it! See what happens and then please get back to us with what you've discovered.

Similar Threads

  1. constructors
    By droidus in forum New To Java
    Replies: 3
    Last Post: 04-28-2011, 08:14 PM
  2. Replies: 5
    Last Post: 11-21-2010, 02:08 PM
  3. Need help with constructors
    By tpfaff in forum New To Java
    Replies: 10
    Last Post: 10-22-2010, 04:33 AM
  4. Constructors
    By suresh.sa in forum New To Java
    Replies: 5
    Last Post: 10-20-2010, 12:10 AM
  5. constructors?
    By shroomiin in forum New To Java
    Replies: 4
    Last Post: 10-13-2009, 02:14 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
  •