javajava-memidplcduicldc

append() method of J2ME


We know that in Java when a method returns a value we have to store that value in a variable of that type.

For example the getString() returns String and we store that value in a String variable.

In J2ME I was trying to create radio-buttons i.e. using the ChoiceGroup class.

ChoiceGroup radio;
radio=new ChoiceGroup("Select your Color",Choice.EXCLUSIVE);
radio.append("Red",null);
radio.append("White",null);
radio.append("Green",null);

In book the signature of append() method is

int append(String string, Image img)

I want to ask that even though I am not storing the integer value returned from the append() method my code runs perfectly.

I am using Wireless toolkit 2.5.2

Note the book has not given any reasons for this and that's why I asked here.


Solution

  • We know that in Java when a method returns a value we have to store that value in a variable of that type.

    Every part of that sentence is false.
    You should get a better book.