You are not logged in. Please login at www.codechef.com 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.*;
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

paragpoddar's gravatar image

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

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×111

question asked: 12 Feb, 01:50

question was seen: 66 times

last updated: 12 Feb, 03:01