| |

VerySource

 Forgot password?
 Register
Search
View: 879|Reply: 7

About System.in.read ()? ? ? ? ?

[Copy link]

4

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 11:40:02
| Show all posts |Read mode
How to understand that the return type of this method is integer? ?
  I always think it should be a String. Please help me explain it
Reply

Use magic Report

1

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-8 12:45:01
| Show all posts
(char) System.in.read ()

Just convert the integer to a character
Reply

Use magic Report

3

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-11 12:18:01
| Show all posts
This method returns not the data content read by READ (), but the number of bytes read. Note that the READ () return type is different in each class in the IO package!
Reply

Use magic Report

3

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-11 12:27:01
| Show all posts
Specific can see API documentation
Reply

Use magic Report

1

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-22 03:00:01
| Show all posts
it depends on the return type not by the sense.
Reply

Use magic Report

0

Threads

6

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-2 11:00:02
| Show all posts
System.in is an InputStream, which means that it is performed in bytes. When the method read () is called, of course, it is read byte by byte, naturally it is char
Reply

Use magic Report

0

Threads

6

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-2 11:45:01
| Show all posts
It is an ACSII, so it must be converted to char
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-5 16:00:01
| Show all posts
Do not use System.in's read method directly. . .

Any book will tell you, don't do it!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list