Questions tagged [system.out]

Predefined stream object attached to the standard output in Java console applications.

It's a static variable in Java's System class. This tag is intended for questions about Java applications that write to the standard output.

404 questions
2977
votes
3 answers

Why is printing "B" dramatically slower than printing "#"?

I generated two matrices of 1000 x 1000: First Matrix: O and #. Second Matrix: O and B. Using the following code, the first matrix took 8.52 seconds to complete: Random r = new Random(); for (int i = 0; i < 1000; i++) { for (int j = 0; j < 1000;…
Kuba Spatny
  • 26,618
  • 9
  • 40
  • 63
132
votes
13 answers

How to color System.out.println output?

How can I color Java output? For example in C and other languages I can use ANSI-escape like \033[0m to do this. But in Java it doesn't work. public static void main(String[] x) { System.out.println("\033[0m BLABLA \033[0m\n"); }
Davide Aversa
  • 5,628
  • 6
  • 28
  • 40
92
votes
11 answers

How can I make Java print quotes, like "Hello"?

How can I make Java print "Hello"? When I type System.out.print("Hello"); the output will be Hello. What I am looking for is "Hello" with the quotes("").
Roy
  • 967
  • 2
  • 8
  • 7
67
votes
7 answers

difference between System.out.println() and System.err.println()

What is the difference between System.out.println() and System.err.println() in Java?
user354299
  • 2,945
  • 5
  • 20
  • 10
63
votes
19 answers

What's the meaning of System.out.println in Java?

Is this static println function in out class from System namespace? namespace System { class out { static println ... } How can I interpret this name? And where in JRE this function is defined? In java.lang.System/java.lang.Object?
prosseek
  • 182,215
  • 215
  • 566
  • 871
39
votes
3 answers

What is System, out, println in System.out.println() in Java

Possible Duplicate: What's the meaning of System.out.println in Java? I was looking for the answer of what System, out and println are in System.out.println() in the Java. I searched and found a different answer like these: System is a built-in…
Dinup Kandel
  • 2,457
  • 4
  • 21
  • 38
26
votes
9 answers

How does System.out.print() work?

I have worked with Java for a quite a long time, and I was wondering how the function System.out.print() works. Here is my doubt: Being a function, it has a declaration somewhere in the io package. But how did Java developers do that, since this…
kishoredbn
  • 2,007
  • 4
  • 28
  • 47
23
votes
2 answers

Why does `System.out.println(null);` give "The method println(char[]) is ambiguous for the type PrintStream error"?

I am using the code: System.out.println(null); It is showing the error: The method println(char[]) is ambiguous for the type PrintStream Why doesn't null represent Object?
Kannan Thangadurai
  • 1,117
  • 2
  • 17
  • 36
20
votes
8 answers

What is the equivalent of Java's System.out.println() in Javascript?

I am writing some tests for Javascript code and I need to dump some messages during the compile process when errors are encountered. Is there any equivalent to Java's System.out.println() in Javascript? P.S.: I also need to dump debug statements…
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
20
votes
3 answers

Why don't we close `System.out` Stream after using it?

I just want to know, we usually close streams at the end, but why don't we close System.out PrintStream with System.out.close()?
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
19
votes
3 answers

Race between System.out and System.err in java

Please consider this java code: public class CMain { public static void main(String[] args){ for (int i = 0; i < 10; i++) { System.out.println("A"); System.err.println("B"); } } } By a quick look at…
C graphics
  • 7,308
  • 19
  • 83
  • 134
18
votes
4 answers

How to make a Logger for System.out

I am wondering how to get org.slf4j.Logger for System.out. I know this is not good, but I need it for testing purposes. Thank you so much.
Anton K.
  • 933
  • 3
  • 9
  • 22
18
votes
5 answers

System.out.print doesn't output to console when running from Junit

When running: public static void main(String... args) throws InterruptedException { while (true) { System.out.print("."); Thread.sleep(200); } } vs. when running same code from junit: @Test public void test() throws…
Lika
  • 1,043
  • 2
  • 10
  • 13
16
votes
9 answers

How to set a string's color

Does anyone know how I would set the color of a string that will be printed using System.out? This is the code I currently have: System.out.println("TEXT THAT NEEDS TO BE A DIFFERENT COLOR.");
guess who
15
votes
10 answers

How can I disable System.out for speed in Java

I'm writing a program in Java that simulates gravity, and in it I have a bunch of log statements (to System.out). My program is running really slowly, and I think the logging might be part of the reason. Is there any way to disable System.out, so…
Gavin S. Yancey
  • 1,216
  • 1
  • 13
  • 34
1
2 3
26 27