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
3
votes
0 answers

Eclipse console not printing colors

I'm trying to print colored text to eclipse console using ANSI Sequences (as described for example here: How to print color in console using System.out.println?). I've tried multiple approaches, most recently a very implicit one: public static final…
MSH
  • 163
  • 1
  • 1
  • 17
3
votes
2 answers

char array vs int array in java while printing the base value of array

In java while printing char array it gives null pointer exception but in case of integer array it prints null public class Test { char c[]; int a[]; //while printing c it gives null pointer exception public static void…
3
votes
1 answer

How do i make it so that spaces generate so the outcome is different

I would like the output to have 9 spaces then a star, 8 spaces then two stars, 7 spaces and 3 stars and so on until 10 stars at the bottom. How can I generate the spaces? import java.util.Scanner; public class ThreeDotTwelvea { public static…
user7082793
3
votes
4 answers

Mutithreading with System.out.format and System.out.println

I came across this example on Oracle's Java Tutorial describing Deadlock in multi threading scenarios. So in this example I made following change at line 17 and line 18. public class DeadLock { static class Friend { private final String…
Steve
  • 889
  • 1
  • 12
  • 26
3
votes
4 answers

How do i use a variable outside the onResponse in Android?

I have created an activity in which i insert some records into a mysql database. I declared a global variable named lastInsertId. When i try to println the variable inside the onResponse method, works fine but when i try to println outside the…
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
3
votes
3 answers

Swift 2 print(), how to hide?

prior to Swift 2 you could hide all your println() for release by having a little helper like this func println(object: Any) { #if DEBUG Swift.println(object) #endif If you change this to func print(object: Any) { #if DEBUG …
crashoverride777
  • 10,581
  • 2
  • 32
  • 56
3
votes
2 answers

Scala how to print contents of a class's returned string and not Class@3c8bdd5b

Is there an easy way to print the contents of what is returned from a new class object? I am testing with Fun Suite. Please see example below: test("test") { val contentString = new TestClass("test") println("CONTENT IS: " + contentString) } The…
tigga4392
  • 111
  • 1
  • 5
3
votes
4 answers

System.out.println doesn't print a line with no parameters?

public class Test2 { public static void mystery(int x, int y, boolean b, String s) { System.out.println(x*3 + "..." + x/y); if (b) System.out.println("yes"); else System.out.println("no"); …
aaa
  • 99
  • 1
  • 1
  • 7
3
votes
5 answers

Java mysterious output from additions: some evaluated, some printed

I was doing java assignment and I ran into this code. int x=3, y=5; System.out.println(x + y + " = " + y + x); and the output is "8=53". Why does the first x+y gets evaluated and the last y and x expression gets printed? Left me wondering. Thanx in…
3
votes
5 answers

Swift println command does not output in console

Using a playground file in Xcode 6 beta, I am trying to get an output in the console for the println command. I have written println("test"), opened the Assistant Editor (View\Assistant Editor\Show Assistant Editor) and see that little window named…
OscarWyck
  • 2,515
  • 5
  • 21
  • 26
3
votes
6 answers

System.out.println and String arguments

When I write: System.out.println("Give grade: ", args[0]); It gives the error: The method println(String) in the type PrintStream is not applicable for the arguments (String, String). Why is this so? However, when I try to…
user3265784
3
votes
3 answers

Is there a way to use Java PrintWriter to write to a specific line?

I have a Java program that uses PrintWriter to write text to a file using lots of .println() statements, everything works fine. What I want to know is: is there a way to write to a specific line in the output file? for example If my program writes…
Stephen Walsh
  • 815
  • 4
  • 18
  • 34
3
votes
3 answers

Is println method accessor or mutator in JAVA?

In System.out.println, println is a accessor or mutator method in JAVA ? Thank you....
Dharmesh
  • 132
  • 1
  • 12
3
votes
3 answers

How can I find a mysterious message being printed?

Okay, so I have a very large project in Java that I have been working on for years (a game, if you must know). Unfortunately, a mysterious message has started being printed. No matter the lengths of my searching, I cannot pinpoint the location of…
David Harris
  • 2,697
  • 15
  • 27
3
votes
2 answers

why is System.out.prinln out of order?

Every now and again I want to use System.out.prinln to debug things instead of using a debugger, or I want a simple program to write to standard output so that I can log something without taking the time to get proper logging set up. I've noticed…
David
  • 14,569
  • 34
  • 78
  • 107