Multipliction table app in Android Studio (JAVA)

package com.example.multiplicationtable;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
TextView textView;
EditText num;
Button button;
String result;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
num = findViewById(R.id.num);
button = findViewById(R.id.button);

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

int sum = Integer.parseInt(num.getText().toString());
result = " ";
for(int i = 1; i<=10; i++){

result += sum + " " +"*" + i +" = " + (sum*i) + "\n";
textView.setText(result);
}

}
});
}
}

Comments