java - How to get the 3rd element of an Arraylist as the sum of first two elements in an ArrayList in Android -


i pretty new programming world, kindly me in solving solution.

kindly consider suppose have x , y values. need add arraylist , z third element z's initial value 0 , next iteration onward z's value becomes sum of ((x[1] - x[0])+ (y[1]-y[0]))? how add values z , how sum of z?

try this,

you can add x values , y values in arraylist of integer or type , this,

int xsum, ysum, totalsum; arraylist<int> zsumlist;  zsumlist = new arraylist<int>;  zsumlist.add(0,0);  for(int = 1; < numberoftimes;i++) {     xsum = x[i] - x[i-1];     ysum = y[i] - y[i-1];      totalsum = xsum + ysum;      zsumlist.add(i,totalsum); } 

hope helps.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -