我们知道,在 Java 中,当一个方法返回一个值时,我们必须将该值存储在该类型的变量中。
例如,getString() 返回 String,我们将该值存储在 String 变量中。
在 J2ME 中,我试图创建单选按钮,即使用 ChoiceGroup
类。
ChoiceGroup radio;
radio=new ChoiceGroup("Select your Color",Choice.EXCLUSIVE);
radio.append("Red",null);
radio.append("White",null);
radio.append("Green",null);
书中append()方法的签名是
int append(String string, Image img)
我想问一下,即使我没有存储从 append() 方法返回的整数值,我的代码也能完美运行。
我正在使用无线工具包 2.5.2
请注意,这本书没有给出任何理由,这就是我在这里提问的原因。
最佳答案
We know that in Java when a method returns a value we have to store that value in a variable of that type.
那句话的每一部分都是错误的。
你应该买一本更好的书。
关于java - J2ME的append()方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9756338/