java - Android How change the value of an element of ArrayList<Integer>()? -


I want to change the value of an element in the list.
I have tried this code:

  from the list & lt; Integer & gt; Numbers = New Arreelist & lt; Integer & gt; (); Numeros.get (2) 12 =;  

But this gives an error. Can someone please help me? Thank you.

You can use the method defined in the ArrayList class.

Answer Your question needs to be done simply by:

  numbers.set (2, 12);  

But , be careful with this. Index value must be index or you can app your app to any IndexOutOfBoundsException . Will crash with.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -