Questions tagged [println]

In programming, `println` generally prints out the arguments given, then moves to a new line for subsequent output.

In programming, println generally outputs the arguments supplied, then moves to a new line for any further output operations. For example, in Java you could write the following:

System.out.print("Hello ");
System.out.println("World");
System.out.println("Goodbye");

And the console would output (with \n representing newline characters):

Hello World\n
Goodbye\n

There are several languages that use the println() method; Others have different syntax that accomplishes the same functionality.

617 questions
7
votes
2 answers

Gradle always does println from any task

I have simple build.gradle (or any build.gradle with task that has println) println GradleVersion.current().prettyPrint() task task1{ println 'task1 starting' } Now when I run $ gradle build I always see tasks executing or print output task1…
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
7
votes
3 answers

System.out.println function syntax in C++

I want to create a function in C++ using cout that has the same as the println function in java. This means that the call should be something like this: int a=5 println("A string" + a); the variable a should have any basic type. What kind of…
Hanelore Ianoseck
  • 594
  • 1
  • 5
  • 12
7
votes
3 answers

println does not print the expected value

This is my code: public static void main(String[] arg) { String x = null; String y = "10"; String z = "20"; System.out.println("This my first out put "+x==null?y:z); x = "15"; System.out.println("This my second out put…
someone
  • 6,577
  • 7
  • 37
  • 60
7
votes
2 answers

Can I talk Java into printing to the console under Mountain Lion?

I'm using the good old System.out.println - approach to debug my Java application. Before I upgraded to Mac OS 10.8 this worked wonderfully. Now however my console wouldn't display anything. Apparently I'm not the first one to encounter this…
Maximilian Tyrtania
  • 437
  • 1
  • 4
  • 14
6
votes
4 answers

Multiple threads using System.out.println in Java

I have a multi-threaded Java application that will output information about a message it receives to the console for debugging purposes. Each time the application receives a message, it will call a System.out.println(String) on the message. The…
Phanto
  • 1,147
  • 5
  • 16
  • 19
6
votes
2 answers

How is the function println not pure? (Clojure)

It always returns nil. Doesn't that mean it's pure? Does println cause any side effects??
toreohm
  • 75
  • 6
6
votes
1 answer

writing data to console at the same time printinf information in java

I want to know how to control the console print format. My problem is that I have 2 threads, one of them constantly prints information to the console, and the other constantly asks the user to write information, but while writing if the other thread…
6
votes
1 answer

How do I remove the space between printed lines?

I created this program to help draw a map in a text adventure I am creating. So far all it does is draw a black square of detentions you input. Is there a way to remove the space between each line so there aren't white lines running through the…
tarboy9
  • 63
  • 6
6
votes
2 answers

Scala println in a for loop

The following Scala code does just what I expect it to - it prints each line of some_file.txt. import scala.io.Source val lines = Source.fromPath("some_file.txt").mkString for (line <- lines) print(line) If I use println instead of print, I…
user293361
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

different behaviour of println() in java

//take the input from user text = br.readLine(); //convert to char array char ary[] = text.toCharArray(); System.out.println("initial string is:" + text.toCharArray()); System.out.println(text.toCharArray()); Output: initial string…
dev
  • 137
  • 1
  • 1
  • 5
6
votes
3 answers

Cannot find symbol println

I just started a new java project today, and I'm having a problem with println. Here's my main method: public static void main(String[] args) { String stringNumGuards = JOptionPane.showInputDialog("How any guards do you have?"); int…
ellman121
  • 1,815
  • 3
  • 16
  • 24
6
votes
5 answers

java System.out.println() strange behavior long string

Can somebody explain me why this code does not print the numbers? String text = new String("SomeString"); for (int i=0; i<1500; i++) { text = text.concat(i+""); } System.out.println(text); Result …
SVetterIO
  • 113
  • 1
  • 7
5
votes
1 answer

Why my graphics code don't run unless there is a System.out.println in the code block?

I have this method paint() which receive a Graphics2D parameter. The weird thing that happen is that unless there is a System.out.println present(which i comment out in the block below), the canvas will not draw anything. public class Map{ …
Phat RedDevil
  • 63
  • 1
  • 6
5
votes
1 answer

Kotlin's REPL println not printing to new line, instead prints everything to same line

I'm using the Kotlin REPL from Intellij Idea. When I type this: println("line 1 ") println("line 2 ") print("same ") print("line") I expect this output: "line 1 " "line 2 " "same line" But instead I get: "line 1 line 2 same line" Why?
C. Rib
  • 340
  • 3
  • 19
5
votes
9 answers

Should I use System.out.println() or something else?

I've been casually programming in Java for a while, but I still have a few burning questions on the fundamentals. I've heard that I should use System.out.println() to display data from some people, and others have given me different ideas (like…
Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151