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
6
votes
2 answers

java printing char array

I am running this code and char[] str = { 'a', 'b', 'c', 0, 'c', 'c', 'f' }; System.out.print(str); System.out.println(" adksjfhak"); This prints just "abc". while, char[] str = { 'a', 'b', 'c', 0, 'c', 'c', 'f'…
sakura
  • 392
  • 1
  • 4
  • 12
6
votes
2 answers

if statement inside the print statement?

How can I write an if statement inside the print statement? public boolean checkEmpty() { if(array.isEmpty) { Sytem.out.println("The List is empty"); } else { System.out.println("The list has: " + if(array.size()…
mohamed ghassar
  • 119
  • 1
  • 2
  • 7
6
votes
3 answers

Intercept System.out and prepend date time in Java

is it possible to intercept calls to System.out.print* and System.err.print* (in Java) and prepend a time stamp to them? Don't worry, we use the usual logging frameworks, but occasionally some sys.out leaks out and it would be nice to know when it…
Ben Smith
  • 1,554
  • 1
  • 15
  • 26
6
votes
1 answer

java difference StdOut vs System.out.println

I have just started working on java, As i downloaded the eclipse and created a java project. Project was working fine, then i imported a class but it's not working due to following lines StdOut.println(p + " " + q); after searching i have…
Haseeb Asif
  • 1,766
  • 2
  • 23
  • 41
5
votes
1 answer

Formatting java strings with system.out.printf

I've been looking around at a lot of questions about the System.out.printf in java for formatting string outputs and I just don't seem to understand how to use it. I'm trying to print nice columns that looks like this 601 GoPro Hero5 Black …
user4780727
5
votes
2 answers

What is a relationship between System class and PrintStream Class

I'm trying to know what exactly System.out.println(). I read these two articles What is System, out, println in System.out.println() in Java and What's the meaning of System.out.println in Java?. I know what is System,out,and print, But i don't know…
Aanshi
  • 282
  • 1
  • 5
  • 22
5
votes
3 answers

why we use system.out.flush()?

Can someone please explain why we we would use system.out.flush() in a simpler way? If there could be a chance of losing data, please provide me with an example. If you comment it in the code below nothing changes! class ReverseApp{ public…
Ali Kashanchi
  • 8,620
  • 3
  • 14
  • 11
5
votes
2 answers

Do strings used in a System.out.println also create new immutable objects?

So I'm studying for the SCJP from the Kathy Sierra book. In the chapter for strings, this is a question: String s1 = "spring "; String s2 = s1 + "summer "; s1.concat( "fall "); s2.concat(s1); s1 += "winter"; System.out.println(s1+"…
Nilay Panchal
  • 541
  • 6
  • 17
5
votes
7 answers

Does the System.out object belong to class System or class PrintStream?

I'm new to programming and I just started learning Java. I'm curious that does the object System.out belong to class System or class PrintStream? I referred to a textbook, JAVA CONCEPTS 4/e. The textbook states that to use the out object in the…
user2236096
  • 1,537
  • 3
  • 13
  • 19
5
votes
4 answers

What is the type of System.out in Java?

I am just a newbie in Java. I was wondering the way System.out.println() is used. Out is a static field inside System class. The type of out is PrintStream. But when I saw the constructor of PrintStream class, it takes a parameter of type…
abhithakur88
  • 397
  • 6
  • 18
4
votes
2 answers

System.out is not recognised

This is driving me absolutely crazy. I have a package that was working fine, then I renamed the package and now I cannot use System.out (or anything in the System class). For what it's worth here is my Main class (I've removed EVERYTHING except the…
takesides
  • 127
  • 1
  • 1
  • 10
4
votes
1 answer

In java, How System.out.println method works in both static and non static context?

How System.out.println method works in both static and non static context? Is there any JVM specific implementation is the answer for this?
bpn
  • 47
  • 3
4
votes
0 answers

Restoring the System.out - PrintStream

I recently recognized that you're able to close the PrintStream System.out! So the code snippet: System.out.println("foo"); System.out.close(); System.out.println("bar"); will produce the output: foo instead of: foo bar Now to my question: Is…
ParkerHalo
  • 4,341
  • 9
  • 29
  • 51
4
votes
0 answers

System out, in and err streams declared null

I looked at java.lang.System source code and found the following lines: public final static InputStream in = null; public final static PrintStream out = null; public final static PrintStream err = null; I know that a final reference can't be…
Brrch
  • 331
  • 1
  • 4
4
votes
4 answers

System.out.print of string without 'ln'

I have a byte array which looks like this: [0, 0, 0, 0, 0, 0, 0, 0, 122, 98, 117, 54, 46, 0, 0, 115, 122, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 116, 121, 116, 117, 108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 107, 111,…
Rop
  • 217
  • 2
  • 12
1 2
3
26 27