Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No collections? Tough teacher you got there....</p> <p>In the absence of a Map you could try creating a separate <code>getPremiershipChampion</code> method. </p> <p>Like this:</p> <pre><code>public PremiershipYear getPremiershipChampion (String userYear, String[] kd) { while(kd.hasNext()){ String data = kd.nextLine(); String [] values = data.split(","); String year = values[0]; if (userYear.equals(year)) { PremiershipYear py = new PremiershipYear(); py.setWinner(values[1]); py.setRunnerUp(values[2]); // Set whatever you need to here... return py; } } return null; } </code></pre> <p>...then call it like this:</p> <pre><code>PremiershipYear year = getPremiershipChampion (userYear, kd); // Get the winner if (year != null) { System.out.println("Winner for "+userYear+"="+year.getWinner()); } </code></pre> <p>Here is the <code>PremiershipYear</code> class:</p> <pre><code>public class PremiershipYear { private String winner; private String runnerUp; private String third; private String fourth; private String faCupWinner; private int someScore; public String getWinner() { return winner; } public void setWinner(String winner) { this.winner = winner; } public String getRunnerUp() { return runnerUp; } public void setRunnerUp(String runnerUp) { this.runnerUp = runnerUp; } public String getThird() { return third; } public void setThird(String third) { this.third = third; } public String getFourth() { return fourth; } public void setFourth(String fourth) { this.fourth = fourth; } public String getFaCupWinner() { return faCupWinner; } public void setFaCupWinner(String faCupWinner) { this.faCupWinner = faCupWinner; } public int getSomeScore() { return someScore; } public void setSomeScore(int someScore) { this.someScore = someScore; } } </code></pre> <p>You can muck about with this to make it more efficient e.g. make <code>kd</code> class level, but this should give you the general idea!</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. VO
      singulars
      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