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

Trying to print a method using another method

Not sure where I'm going wrong with this. I've asked someone in my class and they said there should be an argument with "toonRijSterren". when I do this I just get more errors, could someone have a look and tell me where I'm going wrong? public…
1
vote
6 answers

how can we print (n +nn +nnn) using println for this code?

int n; Scanner in = new Scanner(System.in); System.out.print("Input number: "); n = in .nextInt(); System.out.println(n " + " nn ); //this is not working how can i print using println
karthikaRaj
  • 13
  • 1
  • 3
1
vote
2 answers

Hashmap output in console

I'm working on little "project" for saving some data in a Hashmap which I want to print out later in my console. I've almost finished with the whole code but I'm having problems with giving it out in my console... My code so far is: import…
Default
  • 13
  • 3
1
vote
0 answers

Android: PrintStream.println(String) to .txt file contains <0x00> in java

I am trying to write some data to txt file using PrintStream.println. Some times it is working fine, But some times it is crashing the application. When i saw the result file, It contains <0x00> very huge amount of time. After that nothing printed…
user3619128
  • 285
  • 1
  • 5
  • 12
1
vote
1 answer

Print Treeset return a weird print?

So I have three classes: Lab Student Exam I need to take in input an ID of a Student, add exams of Exam class into a Treeset with Exam type, all of this inside the Student class. After doing that, I need to print this Treeset with an Iterator..…
SlimShadys
  • 119
  • 3
  • 17
1
vote
1 answer

im trying to reduce the number of decimals in a double to 8 using println and rounding the last digit up

I've been assigned to output a double: myD=1.0/3.0; //using println as 0.33333334 = 1/3. I have tried to use a little bit of formatting with no success. //0.33333334 = 1/3; //only using println double myD = 1.0/3.0 System.out.println("%0.8f",…
Benjamin
  • 13
  • 4
1
vote
2 answers

How to make the systemprintln statement to print only the arraylist values without repeating the text

How to print only the arraylist values without repeating the highlighted text part referred the solutions provided but looks complex, please provide a simple solution on how to print only the values import java.util.Arrays; public class…
user9286331
1
vote
1 answer

In-Place Update for print()-Function

basically I want to do the following: let's say I have two methods: def printA(i: Int){ print("Value A: " + i) } def printB(j: Int){ print("Value B: " + j) } Now - for example - I use this both methods do print out some results for a…
scalaNewb
  • 11
  • 2
1
vote
1 answer

Java: different output when scanning input with spaces or enters as delimiters

I'm trying to get input from the user and print it to the console using Java 8 (IDE BlueJ, Windows 10). When printing the output there is a bug: the program prints Equation 2 twice instead of printing Equation 1 and Equation 2. This is the…
noam steiner
  • 4,034
  • 3
  • 27
  • 42
1
vote
3 answers

Learning a Constructor - No output

I am a newbie and learning methods and constructors. Questions as follow When I run the below program in Eclipse, I am prompted an error that I can declare main method as static. public class Mouse { double version; …
Raptor
  • 11
  • 1
1
vote
1 answer

out.println(); not working Java SocketServer

I'm trying to send a message to the server through a client, but I do not see the message on the Server. It shows it's connecting properly. I think the issue has something to do with this, in the Client class but I'm not too sure. Please let me know…
1
vote
2 answers

Print variable from right to left in java

I want to print variable from right. This is my code to show '#' symbol: static void printNumberSignVertical(int n, boolean newLine){ for(int i = 0; i < n; i++){ System.out.print('#'); } if(newLine){ …
dazzle
  • 109
  • 2
  • 15
1
vote
3 answers

Printing variable values in Java

I've got an object which is a new MimeMessage called message and I want to find out what it's passing to my outgoing mail server. I however have no idea how one gets a variable like this printed out in Java. Here's some code: private String…
estubey
  • 13
  • 2
  • 5
1
vote
2 answers

Non-daemon threads output sometimes disappear until join() being used

I have a small test using just two threads as follows: import static java.lang.System.out; @Test public void testTwoSimpleThreads() { doInParallelAsync(() -> { out.println("First Ok"); }, () -> { …
Hearen
  • 7,420
  • 4
  • 53
  • 63
1
vote
1 answer

Unable to print Non English (Latvian) Characters from pdf file correctly in Java using PDFBox?

import java.io.File; import java.io.IOException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException; import org.apache.pdfbox.text.PDFTextStripper; public class sample { public static…