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

How to print the results of a split in Java

How do I make this print the contents of b rather than its memory address? public class Testing { public static void main (String [] args){ String a = "A#b#C "; String[] b = a.split("#"); System.out.println(b); } }
user1212818
2
votes
6 answers

Why is Java not printing all the words in the line (when words are added to an ArrayList)?

When printing out the user input as indvidual words within a line I get a printout of all the words in that line. System.out.println(userInput.next()); However, when I add the indvidual words to an ArrayList I appear to be getting random words…
Sheldon
  • 9,639
  • 20
  • 59
  • 96
2
votes
4 answers

Does system.out.println have to be on edt?

I was running some code that did a printout in a swingworker. I was not getting printouts so I used SwingUtilities.invokeLater and now it works. I did not expect this result, how did this happen? I would have thought System.out.println could run…
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
2
votes
2 answers

Why we can't call 'println()' method with help of PrintStream class where out is object of this class?

Why we can't call println() method with help of PrintStream class where out is object of this class? import java.io.*; class Demo { public static void main(String[] args) { PrintStream.out.println("Hello"); } }
Java Criminal
  • 37
  • 1
  • 4
1
vote
2 answers

Grails: println only works sometimes or something

I make a brand new grails project and put this in the bootstrap: ExpandoMetaClass.enableGlobally() Integer.metaClass.precision = {->return 1} println 3.precision() println "rofl" println 15.precision() And it does what I expect, run-app…
Mikey
  • 4,692
  • 10
  • 45
  • 73
1
vote
1 answer

Is there a way to override the default object printing

I am trying to print an class in scala. Defined below: class Player(balance : Int, player_num :Int ){ var curHand = new ArrayBuffer[Int]() var sum = 0 def method1()={ .... } } I want to print to console with something along…
kmdent
  • 1,577
  • 16
  • 32
1
vote
4 answers

Printing a " in a Java String

Possible Duplicate: How do I make a string with a " character in it? (Java) I am having trouble printing a string like this in java System.out.println("this is a "test""); How can I go about this?
C K
  • 47
  • 5
1
vote
3 answers

Strange java print output

I am new to Java and was working with simple printing. First, I executed: System.out.println(1 + 2 + "3"); Output:33 I made up logic that 1 and 2 will be added and 3 will be printed as is. Then, I tried this: System.out.println ("1" + 2 +…
sum2000
  • 1,363
  • 5
  • 21
  • 36
1
vote
1 answer

understanding issue - System.out.println

I'm new to programming and started out with Java today. I'm reading the online version of 'Introduction to programming in Java' by Robert Sedgewick and Kevin Wayne and using the DrJava editor. There is a particular exercise that left me…
Kadir
  • 11
  • 2
1
vote
6 answers

Java: Can't get incremented value to print.

I'm learning to do some Java 101 syntax stuff. In an exercise I'm trying to do, I can't get the incremented value to print. Any ideas? Here is my code: class StaticTest { static int i = 47; } class incrementable { static void…
phill
  • 13,434
  • 38
  • 105
  • 141
1
vote
3 answers

Clojure: apply println to multiple strings scrambles output

In Clojure 1.11, I'm evaluating this term: (apply println "foo\n" "bar\n" "baz\n") I expect the following output: foo bar baz However, I'm getting this: foo bar b a z The first line is as I need it. The second line contains a leading space. The…
Patrick Bucher
  • 1,302
  • 2
  • 14
  • 36
1
vote
3 answers

Java - Print statement in for loop not printing anything

I wrote simple for loop to print the first character from the beginning of the string then first character from the end.. etc, but the print statement doesn't show anything, why? public class JavaOOP { public static void main(String args[]){ …
aasem shoshari
  • 190
  • 2
  • 14
1
vote
0 answers

Print User input to physical printer in Golang

I'm new here in Golang world for a week.. I've been research and still don't know how to print from user input to physical printer, from USB to printer. For example I have done with code, just need add other function to print.. package main import…
1
vote
1 answer

How to print line to cursor in java (eclispe ide)?

Once upon a time, I had taught myself how to output a series of characters wherever my mouse cursor had last clicked; i.e, I was using it to spam cheats in AOEii campaigns. It pressed enter, printed the characters in "to smithereens", and pressed…
1
vote
1 answer

Making a calculator that does operation of x number of numbers

package com.company; import java.util.*; import java.lang.*; public class ENCRYPTED { public static void main (String args[]) { //Declaring scanner Scanner sc = new Scanner(System.in); //Declaring Arrays …
Programmer
  • 41
  • 4