I need help making a java constructor that akes a string and initilizes the value var with appropriate in [closed]

Firstly if you want to equal “value” TO “a”, you must write:

this.value = a;

in Java (and a lot of programming languages), you must write variable that you change before equal mark.

Second, if you will make “value” Integer. You must change it to int first:

try {
   this.value = Integer.parseInt(a);
} catch (NumberFormatException e) {
    e.printStackTrace();
}

Third, if “value” is an Integer. You must define that with numbers:

value = ""; //if value is an Integer, delete this line.

Leave a Comment