Question: why is createArrayList the only method getting called. I am trying to call methods such as sortArrayList and maxValue but once I input values, it
why is createArrayList the only method getting called. I am trying to call methods such as sortArrayList and maxValue but once I input values, it just ignores that part (in main) and goes back to createArrayList.
import java.util.ArrayList; import java.util.Scanner; public class CIS231MultiInput { public static void main(String [] args) { ArrayList
System.out.print(" " + sortArrayList() + " "); System.out.println(sortArrayList().size() + " size "); System.out.println("Max value input: " + maxValue(arrList)); }
public static ArrayList
System.out.println("Enter a line of input with any number of integers"); System.out.println("All values must be white-space-delimited"); System.out.println("Non-integers will be discarded"); System.out.print("->"); String nextLine = keyIn.nextLine();
Scanner lineScan = new Scanner(nextLine);
while (lineScan.hasNext()) { if (lineScan.hasNextInt()) { values.add(lineScan.nextInt()); } else { lineScan.next(); } } System.out.println(" A total of " + values.size() + " integers were input: "); 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; }
public static int maxValue(ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
