Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().
I'd use:
String.format("You are %d%s old.", days, days == 1 ? "" : "s")
instead of string concatenation:
"You are " + days + " day" + (days == 1 ? "" : "s") + " old."
This shows the structure of the resulting string and the parameter types at a glance.
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().
I'd use:
String.format("You are %d%s old.", days, days == 1 ? "" : "s")
instead of string concatenation:
"You are " + days + " day" + (days == 1 ? "" : "s") + " old."
This shows the structure of the resulting string and the parameter types at a glance.
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().
I'd use:
String.format("You are %d%s old.", days, days == 1 ? "" : "s")
instead of string concatenation:
"You are " + days + " day" + (days == 1 ? "" : "s") + " old."
This shows the structure of the resulting string and the parameter types at a glance.
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().
I'd use:
String.format("You are %d%s old.", days, days == 1 ? "" : "s")
instead of string concatenation:
"You are " + days + " day" + (days == 1 ? "" : "s") + " old."
This shows the structure of the resulting string and the parameter types at a glance.
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().
I'd use:
String.format("You are %d%s old.", days, days == 1 ? "" : "s")
instead of string concatenation:
"You are " + days + " day" + (days == 1 ? "" : "s") + " old."
This shows the structure of the resulting string and the parameter types at a glance.
Instead of:
currentSelectedDayLabel.setText("" + chooseDaySlider.getValue());
I'd use:
currentSelectedDayLabel.setText(Integer.toString(chooseDaySlider.getValue()));
This creates just one String
object (the result) instead of two (the empty and the resulting) and a StringBuilder
object to append them.
See also the accepted answer of Java int to String - Integer.toString(i) vs new Integer(i).toString().