Problems converting Integer to String

前端 未结 4 1760
Happy的楠姐
Happy的楠姐 2021-01-14 14:18

I am trying to add two numbers together from EditText fields. So far I have the code below that I believe converts the EditText field \'pos1_deg\' & \'pos2_deg\' into in

4条回答
  •  时光说笑
    2021-01-14 14:48

    (Assuming this is Java...)

    The message is correct. Primitive values (such as int) cannot have methods invoked on them as they are not objects. The associated methods are instead registered on the Integer class statically, so instead you should use:

    result.setText(Integer.toString(degSum));
    

    (This method also takes an optional second argument that lets you specify the base that you want the number output in, so you can get the hexadecimal representation by calling Integer.toString(degSum, 16) for example. Probably not what you need right now but worth bearing in mind.)

提交回复
热议问题