×

# Why I am getting the error java.util.NoSuchElementException while running the code ?

 0  /* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here int i; Scanner sc = new Scanner(System.in); i = sc.nextInt(); } }  asked 12 Feb, 01:50 1 accept rate: 0% 1 the code sc.nextInt() tries to read next Integer value from the standard input but seems like there's no integer input provided. Read more about Scanner methods and Standard Input Output. (12 Feb, 03:01)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×111

question was seen: 66 times

last updated: 12 Feb, 03:01