Question
Help with arrayLists in java. I have a function that gets user input and does a few things which creates an arrayList known as values.
Help with arrayLists in java. I have a function that gets user input and does a few things which creates an arrayList known as values. Then I have another function that does selection sort on that ArrayList. However, the selection sort isn't working properly... here is the code:
import java.util.ArrayList; import java.util.Scanner; public class CIS231MultiInput { public static void main(String [] args) { // Store all values input
System.out.println(); ArrayList
// Output all values using "for in" loop from 2.4 for (Integer next : values) { System.out.print(next + " "); } return values; } public static ArrayList
for(int j = 1; i < someArrayList.size(); i++) { int temp = someArrayList.get(minIndex); someArrayList.set(minIndex, someArrayList.get(i)); someArrayList.set((i), temp); } } return someArrayList; } } Here is the pastebin for easier readability: https://pastebin.com/uf7hMsNd I'm trying to do selection sort. I'm not sure where I went wrong. I can show the selection sort code in python to compare.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started