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
4 answers

How to println a string and variable within the same parameters

I am writing some code right now and I haven't done this in a while, how would I use the println function to write both a string and a variable? I tried the following: System.out.println("randomtext"var); and…
Parker Moore
  • 31
  • 1
  • 1
  • 2
3
votes
3 answers

How to put Input on next line in Java's Scanner utility

I have a basic java question about the scanner utility. Let's say i have a simple program that takes the user input and stores it in a variable. My question is when i run the program that asks for multiple inputs, the cursor starts at the…
VrnRap
  • 33
  • 1
  • 2
  • 7
3
votes
1 answer

Why aren't the "println" messages printing?

I have written this program to create a list, then use the list to populate an array. The method magicCheck then checks to see if the matrix is a magic square. I initially wrote it to be a defined matrix of size 4x4. When I did that, everything…
woollyMammoth
  • 105
  • 1
  • 2
  • 7
3
votes
3 answers

Is it possible to print text that can be edited by the user (for console programs)?

Say I allow the user to edit something, like the phone number in an Address Book (actually, that's exactly what I'm doing). Is there something that I can add to println that will allow me to insert a variable to display as fully editable text? The…
user185842
3
votes
4 answers

input int at printin

i'm trying to fix the script i wrote: import java.util.Scanner; public class Line2 { public static void main (String [] args) { Scanner scan = new Scanner (System.in); System.out.println ("Please enter 4 integers"); …
2
votes
2 answers

How to print a String in multiline Output Java

First of all I'd like to state that, despite the title, this question is not a duplicate of the one I found here: Java multiline string. I read with attention all answers to that question and couldn't find a solution to my problem. The fundamental…
Matteo
  • 7,924
  • 24
  • 84
  • 129
2
votes
1 answer

NullPointerException clojure println

I'm learning clojure and I found a problem in this very ugly, anti-idiomatic, stupid code that I wrote: (ns music-tag.core (:import (java.io.File) (com.echonest.api.v4.EchoNestAPI) (com.echonest.api.v4.Track))) (def api-key…
Siscia
  • 1,421
  • 1
  • 12
  • 29
2
votes
1 answer

Rust read_line() delays stdout buffer until end of scope

I'm trying to get user input from the command line in a more visually pleasing way by printing ">> " before reading what the user types in. Then I simply print what was typed in. use std::io; fn get_input() -> Result { …
Max Gallup
  • 21
  • 1
2
votes
1 answer

How to print full struct path in Debug output?

I have mymod.rs: pub mod mymod { #[derive(Debug)] pub struct mystruct { pub x: i32, } } And main.rs: mod mymod; use mymod::mymod::mystruct; fn main() { let x = mystruct { x: 10 }; …
user16564170
2
votes
0 answers

Printing main method in Scala3(Dotty) gave value as Main$$$Lambda ... Why?

I wrote a code below in Scala . object Main { def main(args: Array[String]): Unit = { println(main) } } It gave output as : Main$$$Lambda$3/1543727556@3930015a Why is this value returned ? Also, When I wrote a simple method like one below…
2
votes
1 answer

Kotlin flow execution issue

I'm studying Kotlin and I have a question about the flow execution of the language. I wrote this code into the Kotlin playground: fun main() { println("Hello,") Thread.sleep(5000L) print("World!") } I expected that the program prints…
mat.mont
  • 23
  • 4
2
votes
3 answers

Is there a specific R function that gives the greatest control over the formatting of printed strings?

Consider the string "Hello \n World!". It appears that the relevant methods for formatting and printing it are print.default, cat, and if need be, format then print or cat. However, each of these seem to be able to do some things that the others…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
2
votes
1 answer

How to prevent threads to visually mix up each others' output?

I have a program running two threads, where one prints status message to the console and the other accepts user inputs. However, because they both use the same console, if I'm partway typing a command using one thread when the other thread prints,…
yomdol
  • 23
  • 3
2
votes
4 answers

How to print strings in multiple lines in a decreasing order?

I'm using Java 8 and I need to get this output: XXXXX XXXX XXX XX X where "X" is a string. I wrote a simple code: String s = new String ("X"); int j = 5; for (int i = 0; i<5; i--) { System.out.println(s); j--; if (j < 1) …
Yan
  • 77
  • 4
2
votes
2 answers

Do while loops stop executing after a while?

So Im experimenting a bit with multithreading currently, since im still pretty new to Java. Now, I have multiple threads that all influence the same long variable. However, it seems that afer a while of not doing anything but checking the if…
LucaW
  • 79
  • 1
  • 6