我正在学习如何设置一个5x5战列舰板,并且不太明白下面的线是如何工作的。
首先我添加 '
public class MainPage extends AppCompatActivity {
EditText smle,cv,gpa;
TextView ans;
Double s,c,g,sum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_page);
smle=(EditText)findViewById(R.id.smle);
cv=(EditText)findViewById(R.id.cv);
gpa=(EditText)findViewById(R.id.gpa);
TextView ans=(TextView)findViewById(R.id.ans);
// here it says that the variable "ans" is never used.
s=Double.parseDouble(smle.getText().toString());
c=Double.parseDouble(cv.getText().toString());
g=Double.parseDouble(gpa.getText().toString());
}
public void onCal(View view)
{
sum=(g*20*0.30)+c+(s*0.50);
//Here it says static member 'java.lang.String.valueOf(java.lang.Object) is accessed via instance reference
ans.setText(toString().valueOf(ans));
生成[range(5)]
,但为什么[0,1,2,3,4]
- “append()
”使所有数字都为“0”?
board.append(['0']*5)