You are not logged in. Please login at to post your questions!


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

    /* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;

/* 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(;
        i = sc.nextInt();

asked 12 Feb, 01:50

paragpoddar's gravatar image

accept rate: 0%


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) taran_14076★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 12 Feb, 01:50

question was seen: 66 times

last updated: 12 Feb, 03:01