0

i am trying to sum String data type

i have code like this :

String x = dis.getText();
        // i assume the value of x is "2+3*4"
        
        dis.setText("Result :" + x);
        // the output is : 2+3*4
        // but i want the result to be 2+3*4 = 14

I've tried changing it to double but it still doesn't work :

String x = dis.getText();
        
        double y = Double.parseDouble(x);
        
        dis.setText("Result :" + y);
LeviantArt
  • 13
  • 2

0 Answers0