| |

VerySource

 Forgot password?
 Register
Search
View: 2884|Reply: 17

Why isn't a program less than 10 lines very normal? Let me help you.

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-16 10:30:01
| Show all posts |Read mode
public class SystemTest
{
public static void main (String args []) throws Exception
{
int count = 0;
System.out.println ("Enter characters, 'q' to quit.");
while ('q'! = (char) (count = System.in.read ()))
{
System.out.print ((char) count);
}

}
}
This program outputs the characters entered by the keyboard to the screen. The program terminates when it encounters the letter q
But after running in eclipse, you can display the output in the console, but why not stop when you press q?
Reply

Use magic Report

1

Threads

21

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 Tunisia

Post time: 2020-4-17 09:45:01
| Show all posts
it's base console
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-17 14:45:01
| Show all posts
Can it be made clear? I do n’t quite understand
Is there a problem with the program? Or is there a problem with the method I checked
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-17 21:45:01
| Show all posts
No error, I tried it, it works very well
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-17 23:15:01
| Show all posts
Is eclipse or javac java directly used upstairs?
Is the keyboard input displayed on the console?
Press q to stop?
Reply

Use magic Report

1

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 Unknown

Post time: 2020-4-18 18:45:01
| Show all posts
mission completed, test passed ...
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-25 19:30:02
| Show all posts
That's the problem with eclipse
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-25 20:30:01
| Show all posts
Nothing wrong, I ran it;
Reply

Use magic Report

0

Threads

21

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-4-26 02:45:01
| Show all posts
When running in an Elipse, Elipse just puts the output stream System. Out intercepted and displayed in the id, but did not realize the redirection of System.in. This program can only be run in cmd, which is the "console" mentioned by the previous brother.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-26 16:45:01
| Show all posts
Okay, I am also a novice and I would like to ask how to rewrite this program in Eclipse?
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