0
why prefer one over the other?
When or why would one prefer to use the System.in stream over the Scanner? They both read input from the console(though with the System.in you have to typecast to String in order to read in a new string, because it reads in bytes?so far i got)... but why prefer one over the other?
1 Odpowiedź
+ 2
Scanner has a nice API to deal with the input in a nice way, like what character to separate on when next() is called. Just like you can use a knife to eat soup but probably shouldn't, everything has a use case that it is designed for. InputStream can take data, Scanner helps to deal with that data in a useful way. Usually a stream is passed to some other object so that it can be handled effectively