How can I read a string in from the user? For example, I am writing a console-based java application which prompt the user to enter a string and then reads that string in. What is the opposite of System.out.println? ;) System.in.readln? I can't get it to work and I'm a Java newbie :(
Dani
4,084
The Queen of DaniWeb
Administrator
Featured Poster
Premium Member
Recommended Answers
Jump to Posthi babe.
if you wana read just a string the simple approach is by using "JOptionPane" dialogs import javax.swing.*;
and where ever you need to get string from user try this syntex
String str = JOptionpane.showInputDialog(null,"Enter String");
now you can use str where ever in your program.
All 3 Replies
Dani
4,084
The Queen of DaniWeb
Administrator
Featured Poster
Premium Member
DARKSTAR
0
Newbie Poster
gusano79
247
Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.