comp sci balla
comp sci balla

Reputation: 823

How do I print a string to the system console?

I've spent the last three hours trying to write a "string" to the "console"?

System.in.writeToConsole("\"string\"");

Upvotes: 0

Views: 246

Answers (6)

edthethird
edthethird

Reputation: 6263

System.out.println("\"string\"");

Upvotes: 1

Gilbeg
Gilbeg

Reputation: 751

You can use the below

System.out.println("\"string\"");

Upvotes: 0

cgrantham
cgrantham

Reputation: 163

So you know about stdin, stdout, and stderr?

  • System.in reads from stdin;
  • System.out writes to stdout;
  • System.err writes to stderr.

Then you have methods like print and println, print will write whatever you give it, println will write whatever you give it with a newline character at the end.

Hope this helps.

Upvotes: -1

yegor256
yegor256

Reputation: 105053

I would recommend to use some logging framework instead. Writing to console is a bad practice.

Upvotes: -2

Jasonw
Jasonw

Reputation: 5064

You should look into system.out. I think you are confused the in and out, please read the link before and this.

Upvotes: 6

Eng.Fouad
Eng.Fouad

Reputation: 117587

It is System.out.println("\"string\"");

Upvotes: 3

Related Questions