07. Attraction

01.Attract each other + mass:

For loop definition to define interaction between each element from the same list:

for (int i = 0; i < arraylist.size(); i++) {
//select element i from the list
   for(int j = 0; j< arraylist.size(); j++){
      //select element j from the list
       //condition to avoid choosing and interacting with the same element

source code

02.Attraction, repulsion, gravity, wind :

source code

See for more:
05.Force & Mass
Nature of code

Comments are closed.