使用charAt()在字符串中进行java赋值

使用charAt()在字符串中进行java赋值,java,Java,如何将a的内容分配给指定的数字索引 当我将字符串a更改为字符ascan.next()不起作用时,为什么我能做什么?有任何字符扫描方法吗?您应该这样做: error: unexpected type at this code: `a.charAt(0)= number.charAt(k);` 无法将某些内容分配给方法。方法仅返回某些内容。String.charAt(int)是一种在指定点返回字符串字符值的方法。使用此方法无法为其分配任何内容。 error: unexpected type at

如何将a的内容分配给指定的数字索引


当我将字符串a更改为字符a
scan.next()
不起作用时,为什么我能做什么?有任何字符扫描方法吗?

您应该这样做:

error: unexpected type at this code: `a.charAt(0)= number.charAt(k);`
无法将某些内容分配给方法。方法仅返回某些内容。

String.charAt(int)
是一种在指定点返回字符串字符值的方法。使用此方法无法为其分配任何内容。
error: unexpected type at this code: `a.charAt(0)= number.charAt(k);`
a = number.charAt(k) + a.substring(1);