0

im having problems with my input. i want the output to look like this

Enter first string:
first <- user input
Enter second string:
second <- user input
The contents are first and second

but the output doesnt look like that and the input is messed up. what seems to be the problem?

import java.util.*;
class Sample
{
public static void main(String[]args)
{
Scanner input=new Scanner(System.in);
String a,b;

System.out.println("Enter first string: ");
a=input.nextLine();
System.out.println("Enter second string: ");
b=input.nextLine();

System.out.println("The contents are "+a+" and "+b+" ");
}
}

Edited by intes77: n/a

3
Contributors
3
Replies
10
Views
6 Years
Discussion Span
Last Post by mr_bit
0

I tried to implement this code. But this let's me input only one string and stores that into b and the content of a is empty.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.