Note that there are some explanatory texts on larger screens.

plurals
  1. POSorting a list of Strings in Alphabetical order
    primarykey
    data
    text
    <p>OK, here is my problem. I need to take a array of Strings and sort it alphabetically and then print out the first String: For example, a string of "Georgia, Florida, Alabama", It should print out Alabama. The Strings are not submitted by the user, i have a file with a bunch of states that is inputed as an array.</p> <p>This is what I have:</p> <pre><code>import java.io.*; import java.util.*; public class MinString { private static final int SIZE = 10; public static void main(String[] args) { String[] list = new String[SIZE]; int numItems; numItems = Initialize (list); System.out.println(numItems); } private static int Initialize (String[] list) { //post : List is initialized with all strings from file. String filename, stateInput; int i = 0, numItems = 0; try { System.out.print("Input File : "); Scanner stdin = new Scanner(System.in); filename = stdin.nextLine(); stdin = new Scanner(new File(filename)); while ((stdin.hasNext()) &amp;&amp; (i &lt; list.length)) { stateInput = stdin.nextLine(); System.out.println("S = " + stateInput); list[i] = stateInput; i++; } numItems = i; } catch (IOException e) { System.out.println(e.getMessage()); } return numItems; } // Method FindMin goes here private static String FindMin (String[] list, numItems); ????? </code></pre> <p>}</p> <p>I'm not sure how to write this FindMin Method. I need to write FindMin so that it takes as input an array of size numItems of strings and returns to the calling function the minimum string. </p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload