Neha Ninave
asked on
Android ArrayList Issue
I have generated ArrayList from class like
and When I check the output of this Array I got
I get an output like
Now I need first value CoinName from this ArrayList so I wrote
coinArrayList= ShowDash.getCoins();
and When I check the output of this Array I got
Log.d("coinArrayList", "" + String.valueOf(coinArrayList) );
I get an output like
D/coinArrayList: [{CoinName=COIN1, CoinBal=0.0, CoinPrice=8919.52}, {CoinName=COIN2, CoinBal=0.0, CoinPrice=101200.0}, {CoinName=COIN3, CoinBal=0.0, CoinPrice=112603.0}, {CoinName=COIN4, CoinBal=0.0, CoinPrice=226263.0}]
Now I need first value CoinName from this ArrayList so I wrote
Log.d("coinArrayList", "" + String.valueOf(coinArrayList.get(0).getCoinName()));
But here I always get null value. Why?
What objects do you have in your List? Is it an object you implemented yourself? If so, look closely at the implementation of the getCoinName() method, and make sure it's doing as you expect. (Maybe compare it to the toString() method, and see if they are both referencing the same CoinName field.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.