hey, thanks for helping me out before i've developed some knowledge of the scanner class now, though i have run into another problem, i have made an example program to show my error.
my program works fine providing that the user will enter a numerical value, but if i add any value that is not numerical i get the errorpackage testpackage; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { System.out.println("input"); //for (int Loop = 0;Loop < 1;){ Scanner sc = new Scanner(System.in); int name = sc.nextInt(); if(name > 0 && name < 41){ System.out.println("Working"); //Loop = 1; }else{ System.out.println("error"); } //System.out.println("Hello"); } //} }
i am unsure how to fix this error, i don't need to parse the character values though i will need it to continue working if the character value is entered.Exception in thread "main" java.util.InputMismatchException
thank you in advanced,
luke.