-2

here is my program

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.Scanner;
public class Solution1 {
 public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
  Scanner in = new Scanner(new InputStreamReader(System.in));
   System.out.println("Enter the INTEGER");
int num = in.nextInt();
  System.out.println("Enter the double");
double d=in.nextDouble();
  System.out.println("Enter the String");
String s=" ";
        s=in.nextLine();
        System.out.println("String:" + s);
        System.out.println("Double:"+d);
        System.out.println("Int:"+num);
    }

}

Output

Enter the INTEGER 1 Enter the double 1.1 Enter the String String: Double:1.1 Int:1

I should display string value but i unable to do please help me out

2 Answers2

1

Put extra nextLine before you read the string like below :

in.nextLine();
s=in.nextLine();
Nitesh Virani
  • 1,570
  • 4
  • 22
  • 40
0

try this:

String s = in.next();
hossein ketabi
  • 418
  • 6
  • 14