How to get input from user using System console

0 votes
I have started working on Console class. But I do not know how to take input using System.console. How can I do this?
May 23, 2018 in Java by Daisy
• 8,110 points

2 answers to this question.

0 votes

If you are working outside the IDE, you can get input using console using the code given below.

System.out.print("Enter something:");
String input = System.console().readLine();
answered May 23, 2018 by Parth
• 4,630 points
0 votes
Scanner in = new Scanner(;

int i = in.nextInt();
String s =;
answered Aug 2, 2018 by Sushmita
• 6,900 points

Related Questions In Java

0 votes
1 answer

Is there a way to mask the password from java user input that comes from Scanner class and System.out.Println()?

You can use the console class to do so. ...READ MORE

answered May 27, 2019 in Java by Omkar
• 69,150 points
0 votes
1 answer

How to take input from users?

Scanner Class is used to take input ...READ MORE

answered Apr 17, 2018 in Java by Akrati
• 3,170 points
0 votes
1 answer

How to download and save a file from Internet using Java?

public void saveUrl(final String filename, final String ...READ MORE

answered May 24, 2018 in Java by Rishabh
• 3,640 points
0 votes
1 answer

How to get the IP address of the machine using Java?

One approach is to use NetworkInterface.getNetworkInterfaces() to get all ...READ MORE

answered Jun 25, 2018 in Java by sharth
• 3,350 points
0 votes
3 answers

How to clear the console in Java?

import; public class chkClearScreen {     public static void ...READ MORE

answered Aug 26, 2020 in Java by ItsJustRaja
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 6, 2018 by Omkar 44,111 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,520 points
0 votes
3 answers

How to read input from Console using Scanner Class?

A simple example: import java.util.Scanner; public class Expl { ...READ MORE

answered Jul 31, 2018 in Java by samarth295
• 2,220 points
0 votes
2 answers

How to read the files using Java?

You can use collections. try (Stream<Path> filePathStream=Files.walk(Paths.get("/home/you/Desktop"))) { ...READ MORE

answered Jul 10, 2018 in Java by Sushmita
• 6,900 points