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 :(
Jump to Post
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
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.