Java equivalent cin (C ++)

how would you encode this in java?

char c; int n; cin >> c >> n; 

So, I can get these inputs:

 X123123 
+7
java c ++
source share
1 answer

You can use Scanner with System.in . For example.

 Scanner s = new Scanner(System.in); char c = s.findInLine(".").charAt(0); int n = s.nextInt(); 
+20
source share

All Articles