Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As I told you in the previous question array cannot be found because it's still in try block. </p> <p>Then for printing you cannot directly print an array in an useful way, you should iterate over every element and print it in the following way:</p> <pre><code>for (int i = 0; i &lt; array.length; ++i) System.out.println(array[i]+" "); </code></pre> <p>Here you are:</p> <pre><code>import java.io.*; import java.io.File; import java.util.Scanner; public class sdfs { public static void main(String[] args) throws IOException { System.out.print("Name of file with array: "); Scanner readIn = new Scanner(System.in); String input = readIn.nextLine(); } public static void testScan1(String filename) { File file = new File(filename); Scanner scan; int[] array; try { array = new int[5]; scan = new Scanner(file); } catch (java.io.FileNotFoundException e) { System.out.println("couldn't open. file not found "); return; } while (scan.hasNext()) { for (int i = 0; i &lt;= file.length(); ++i) { array[i] = Integer.parseInt(scan.next()); for (int j = 0; j &lt; array.length; ++j) System.out.println(array[i]+" "); } } } int partition(int[] arr, int left, int right) { int i = left; int j = right; int tmp; int pivot = arr[(left + right) / 2]; while (i &lt;= j) { while (arr[i] &lt; pivot) i++; while (arr[j] &gt; pivot) j--; if (i &lt;= j) { tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i++; j--; } } return i; } void quickSort(int[] arr, int left, int right) { int index = partition(arr, left, right); if (left &lt; (index - 1)) { ; } quickSort(arr, left, index - 1); if (index &lt; right) { quickSort(arr, index, right); } } } </code></pre> <p>Look how indention help in reading code..</p>
 

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