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(;
String a,b;

System.out.println("Enter first string: ");
System.out.println("Enter second string: ");

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

sorry my problem is already solved.

this won't work in c++ and also, HI

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.