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
1
vote
1 answer

How can I change the size of a System.out.println local variable inside a JFrame

I modified some code I found to display a local variable instead of set text inside of a JFrame, but I'm unable to find a way to change the size of the text. I keep reading about frameName.setFont(new Font(____)), but that doesn't seem to be working…
ddalcanto
  • 51
  • 5
1
vote
1 answer

Question Mark in a Box when using println

When running this in a command prompt, System.out.println(Num + " is prime!"); System.out.println("Press N to put in another number or S to stop"); Where Num is an int This is what comes out: Is there any way to counter it or should I just deal…
1
vote
1 answer

Hamcrest - print to console

I'm testing a function called generateRandomByteInRange. It fails and I want to see the exact value it gets (and not only that it was less than -127). I tried to surround the assert with try - catch and when it fails to print to the console but…
Paz
  • 1,023
  • 4
  • 14
  • 31
1
vote
3 answers

Android Studio : Remove all System.out.println() in a file?

I have used many System.out.println() for debugging purpose which i know isn't a very good idea. Now I want to remove all the print statements without doing it manually. Is there really any shortcut or trick to achieve this using Android Studio?
Arun
  • 782
  • 2
  • 13
  • 25
1
vote
2 answers

How to expand variables with fmt.Println()

I can't expand variables with fmt.Println(). package main import "fmt" func main(){ old := 20 fmt.Println("I'm %g years old.",old) } result => I'm %g years old. 20
Junya Kono
  • 1,121
  • 3
  • 10
  • 16
1
vote
1 answer

Different results, why?

I have code for print MAC address from Java, the code is InetAddress ip; try { ip = InetAddress.getLocalHost(); System.out.println("Current IP address : " + ip.getHostAddress()); NetworkInterface network =…
visent
  • 13
  • 3
1
vote
2 answers

System.out.println() doesn't work as i want in the for loop

Firstly, I'm sorry for my bad english. I wrote my problem in the forums that speak my language. But I did not get an answer. I hope you can help me. When I write the for loop, the System.out.println() or JTextArea.setText() command starts to work…
Salihcan
  • 91
  • 13
1
vote
0 answers

Gradle print vs println

I understand the difference between print and println methods. But why Gradle with default logging level prints output with println but doesn't with print or printf? TaskProgress.groovy public class TaskProgress { private static final String…
Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
1
vote
3 answers

How to copy the terminal output (and input) to a file in java

I want to save all the text on the terminal as a output on a text file. For the output there can be a function to be used instead of System.out.println() class OutSave { String output; public static void main() { output=""; …
1
vote
2 answers

How to print List's object elements in Java?

I have something like the following: List intervals = new LinkedList(); intervals.add(new Interval(1)); intervals.add(new Interval(2)); How can I print the List intervals? I attempted System.out.println(intervals), but it simply…
user6898719
1
vote
1 answer

Removing a println call in java is causing a logical error

I've been working on a program for a few weeks now and someone gave me a suggestion on how to improve it's performance which I am attempting to implement. It is so far working however, I have run into the issue that I cannot comment out one of the…
user2209743
  • 65
  • 2
  • 6
1
vote
0 answers

system.out.println doesn't conforms to system.out.print

system.out.println doesn't conforms to system.out.print when printing a java.util.stream. 1) Stream.of(1, "1B").forEach(System.out::print); result: 11B 2) Stream.of(1, "1C").forEach(System.out::println); result 1 1C 3) Stream.of(1,…
A Skale
  • 11
  • 2
1
vote
2 answers

Java printf statement giving errors

I'm using Eclipse on an a homework assignment and I'm really struggling. The goal is to write a payroll program that has a user enter their name, hours worked, pay rate, federal and state tax withheld, and then outputs the calculated information of…
Carlos
  • 11
  • 2
1
vote
2 answers

Sublime Text 3 wont show output (JAVA)

I have a program in Java that takes the users input of a number, converts it to a string and then reverses the number and prints it out (e.g: INPUT: 789 OUTPUT: 987). This program runs in every other IDE except Sublime Text 3. I'm assuming this is a…
c.timothy
  • 97
  • 10
1
vote
1 answer

Why do I get null after I initialized a string?

I don't understand why Sp1.location returns NULL. If I run the program it seams I can initialize location successfully. I have code a attribute as an integer in a similar way, but that gave me no problems. public class Database { static Scanner…