If they both perform the same task which is to take input from the user, what is the need for the two different methods? Do they have any difference or maybe difference in areas of applications? And which one between them is the best? please help me understand
Scanner is a reader for some kind of typed objects like numbers, string, etc and with Scanner you can read data directly to variable of the type you need
int age = new Scanner(System.in).nextInt();
BufferedReader is just a reader object with internal data buffer. It is used here as an alternative as plain reader does not have "readLine" method and as a result cannot read from user input till the end of line without a lot of additional code.
In my practice I have seen Scanner used only for user input, but BufferedReader is more widely used, actually for every 1st file reading/stream reading as without buffer file/stream java is reading data slowly byte by byte or something like this.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If they both perform the same task which is to take input from the user, what is the need for the two different methods? Do they have any difference or maybe difference in areas of applications? And which one between them is the best? please help me understand
Scanner is a reader for some kind of typed objects like numbers, string, etc and with Scanner you can read data directly to variable of the type you need
int age = new Scanner(System.in).nextInt();
BufferedReader is just a reader object with internal data buffer. It is used here as an alternative as plain reader does not have "readLine" method and as a result cannot read from user input till the end of line without a lot of additional code.
In my practice I have seen Scanner used only for user input, but BufferedReader is more widely used, actually for every 1st file reading/stream reading as without buffer file/stream java is reading data slowly byte by byte or something like this.