Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Currently I have the following: </p> <pre><code>public String[] readCancer() { cancers = new String[22]; split = new String[22]; FileInputStream fis; InputStreamReader isr; BufferedReader br = null; String eachCancer; int j = 0; try { fis = new FileInputStream(myData); isr = new InputStreamReader(fis); br = new BufferedReader(isr); input = new Scanner(br); while(input.hasNext() &amp;&amp; j &lt; 23) { cancers[j] = input.nextLine().toString(); //cancers[j] = input.nextLine(); split[j] = cancers[j].split(":"); //split[j] = "blah"; this line works j++; } System.out.println(Arrays.toString(split)); } catch (IOException iox) { JOptionPane.showMessageDialog(null, "Problem with file input"); } finally { try { if(br != null) { br.close(); } } catch (IOException iox) { JOptionPane.showMessageDialog(null, "Problem closing the file"); } } return split; //return split[j]; does not work } </code></pre> <p>In my while loop, I keep getting compile errors saying it requires a String but found Stirng[] for split. When I try something simpler, such as split[j] = "blah";, there are no compile errors. I can return cancers perfectly but I need to split by the : delimiter and that seems to be something I cant get my head around. When I try return split[j], then I get another compile error saying it requires a String[] but found String. I've been at this for more than an hour, read through examples in my textbook and tutorials online for using split but it still isn't working. This is the only part of my program that I'm not sure how to do. </p>
    singulars
    1. This table or related slice is empty.
    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.
    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