-3
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        String s = scan.next();
        double d = scan.nextDouble();

        // Write your code here.

        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
}

what is the problem in my code i'm new in java

Zippy
  • 3,561
  • 5
  • 34
  • 90
AMOXE pROG
  • 21
  • 1
  • 1
    Welcome to SO. Please be more specific - "what is the problem" and "I'm getting error" helps no one to answer. Error message and description of expected behaviour usually help. – no id May 06 '18 at 23:11
  • For this specific question consider using `nextLine()` – no id May 06 '18 at 23:16
  • 2
    Possible duplicate of [How can I read input from the console using the Scanner class in Java?](https://stackoverflow.com/questions/11871520/how-can-i-read-input-from-the-console-using-the-scanner-class-in-java) – retatu May 06 '18 at 23:34

2 Answers2

0

Problem is here:

String s = scan.next();

Introduce addtional line to skip newline:

String s = scan.next();
scan.nextLine(); /* add this */

OR

Replace that line with:

String s = scan.nextLine();
0

Since the question isn't clear, I'm guessing you have the problem with the string.

This will reads until there is a space.

String s = scan.next(); 

If you want to read a string after the space consider doing this:

String s = scan.nextLine();
BadBoy
  • 26
  • 2