Answer by SimonT for How to reverse an ArrayList without the reverse method?
You can swap in pairs at a time, coming in from both ends toward the center:for (int i = 0; i < nums.size()/2; i++) { Integer left = nums.get(i); Integer right = nums.get(nums.size()-1-i);...
View ArticleAnswer by Thomas W for How to reverse an ArrayList without the reverse method?
You can ascend from the bottom & simultaneously descend from the top (size() - 1) swapping elements, and stop when you meet in the middle.int i = 0;int j = nums.size()-1;while (i < j) { int temp...
View ArticleHow to reverse an ArrayList without the reverse method?
Hello I am trying to reverse an ArrayList without the reverse method. I just wanted to make it work without the method. I can't seem to get it right. This is what i have so far:for (int x =...
View Article
More Pages to Explore .....