+ 1

I need source code to read an integer in java

Pls answer me

3rd Mar 2019, 5:47 AM
Gnane 143
Gnane 143 - avatar
3 odpowiedzi
+ 13
int integer = scanner.nextInt(); or int integer = Integer.parseInt(scanner.nextLine());
3rd Mar 2019, 1:45 PM
Salif Mehmed 🇹🇷🇧🇬
Salif Mehmed  🇹🇷🇧🇬 - avatar
+ 3
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = Integer.valueOf(sc.nextLine().replaceAll("\\D", "")); System.out.print(x); } } --- Don't forget sc.nextLine() can recieve numbers, words and numbers with letters. So you need to use regex.
6th Mar 2019, 10:00 PM
M_N