Java equivalent of cin (C++)

how would you code this in Java?

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

So that I can get this kind of inputs:

X123123 

1 Answer

You can use Scanner with System.in. E.g.

Scanner s = new Scanner(System.in); char c = s.findInLine(".").charAt(0); int n = s.nextInt(); 
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like