samedi 22 août 2015

If statements inside of constructors

I have a class called with an empty constructor and I want to have an if statement that sets a Boolean to true if the constructor has been used in an instantiation of that class. For example:

public class Test {
public float a1;
public int b1;
public double c1;
public Boolean ifConsUsed = false;

public Test(float a, int b, double c, Main app) {
   a1 = a; b1 = b; c1 = c; applet = app;
      if(expression goes here) {
      ifConsUsed = true;
      }
   }

}

In this instance what expression would I put into the if statement to detect if the constructor was used?

Aucun commentaire:

Enregistrer un commentaire