#how to access and modify a local variable in enclosing/inner scope?

6 messages · Page 1 of 1 (latest)

dapper valve
#

public class CalculatorGui {
    public static void main() {
        String lhsNumber = "0";
        String rhsNumber = "0";
        String operator = "";

                                    btn.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent event) {
                            if (operator == "") {
                                lhsNumber = lhsNumber == "0" ? btn.getText() : lhsNumber + btn.getText();
                            }
                        }
                    });
outer sparrowBOT
#

This post has been reserved for your question.

Hey @dapper valve! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

dapper valve
#

how do i access and modify lhsNumber inside the btn function

#

i may have fixed this

#

YES I FIXED IT