Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

why Scanner class not working ?

user575089Dec 29 2017 — edited Dec 30 2017

my keyboard inputs // first an integer and second a string

2

This is a string

my code :

import java.util.Scanner;

public class MyClass {

    public static void main(String args[]) {

    Scanner sc=new Scanner(System.in) ;

   int a=sc.nextInt();

    //float b=sc.nextFloat();

    String str=sc.nextLine();

   

     System.out.println("###");

    System.out.println(a);

    // System.out.println(b);

      System.out.println(str);

}

}

I am not getting two inputs . I am getting 2 only.  what happened to second input ?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 27 2018
Added on Dec 29 2017
10 comments
3,737 views