Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.util.NoSuchElementException Reattempt
    text
    copied!<p>Ok my first question screwed up please review it now.</p> <p>This is my error</p> <pre><code> java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextByte(Unknown Source) at java.util.Scanner.nextByte(Unknown Source) at Filename.getMenu(Filename.java:38) at Filename.main(Filename.java:23) </code></pre> <p>This is my code </p> <pre><code> import java.util.Scanner; public class asdasdasd { public static void main(String[] args){ short[] time = {2008, 2009}; String[] champs = {"Mouths", "Mouths"}; getMenu(time, champs); } public static void getMenu(short[] time, String[] champs){ Scanner keyboard = new Scanner(System.in); byte a; do{ System.out.println("\t\t\tMain Menu"); System.out.println("Select an Option || Example: Type '1' for Seach\n\n"); System.out.println("\t\t1.Search\n"); System.out.print("Input the number: "); a = keyboard.nextByte(); if(a == 1){ getSearch(time, champs); } } while(a &lt; 5); keyboard.close(); } public static void getSearch(short[] time, String[] champs){ Scanner keyboard = new Scanner(System.in); String Team; byte b; do{ System.out.print("\n\nEnter the name of the team: "); Team = keyboard.next(); if("Mouths".equals(Team) || "mouths".equals(Team)){ Team = "mouths"; } System.out.print("Start a new Search?\nInput 1 for Yes or any other number to return to the main menu: "); b = keyboard.nextByte(); } while(b == 1); keyboard.close(); } } </code></pre> <p>Ok so basically the input is 1, then mouths, then 2. And then the error came up.</p> <p>Sorry to everyone who was willing to help and I didn't give much information. I m just scared of getting put down for plagiarism.</p> <p>I've already been told to use hasNext(), or something like that. Never used it at all and I have no experience What so ever. If someone can show me an example or how to use it in this coding that would be great.</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