#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Constructor problems!


    Hi guys!
    I think this should be very simple for someone skilled in java to fix, i've programed other languages pretty much so i understand somethings.

    I have a constructor A(int age, string name) with
    this.age=age , this.name=name

    Now i have a second constructor A()
    which should call the other one, but this one should make random
    objects.

    So i'm using this((int)(Math.random()*100,"name")

    The problem is to make random names i can't put it like
    this(...,names[Math....]) because it tells me i can't call the array before the super conductor, is there any way to give a string to a variable from the array before making the call to the first conductor?

    Help is appreciated!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Fixed the problem by adding a string changer for the name in the code that changes the name after the constructor has called the super constructor

IMN logo majestic logo threadwatch logo seochat tools logo