I have been using the Scanner object to take in input until now and would like to learn how the BufferedReader works. I have tried it and it seems to be working only for Strings. can someone show me how to use it with ints and doubles?and how do you ask for two String inputs on the same line? Thanks.
Share
Think of
BufferedReaderandScanneras being at different levels of abstraction, rather than interchangeable parts that “do the same thing.” I think this is the fundamental issue that you’re hung up on.BufferedReaderis in some sense “simpler” thanScanner.BufferedReaderjust readsStrings.Scanneris much more robust thanBufferedReader. It has APIs that make it easy for extracting objects of various types.I could imagine
Scannerbeing written usingBufferedReaderas an underlying building block. Whereas usingScannerto writeBufferedReaderwould be like killing an ant with a sledgehammer.