Here Some solution for how to copy or replace new arraylist to previous or old arraylist, with costmize new array size or data.
public class MainActivity extends Activity { ArrayList<String> s = new ArrayList<String>(); ArrayList<String> f = new ArrayList<String>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); s.add("Nepal"); s.add("Korea"); s.add("Sri Lanka"); s.add("India"); s.add("Pakistan"); s.add("China"); s.add("Australia"); s.add("Bhutan"); f.add("London"); f.add("New York"); f.add("Mumbai"); f.add("Kathamndu"); // first clear the array otherwise you are adding old array s.clear(); s.addAll(f); for(int i=0;i<s.size();i++){ Log.d("TAG", "Sources---" + s.get(i)); Log.d("TAG", "Destination---" + f.get(i)); } } }
0 comments
Posts a comment