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

Java: showing the output of a separate for loop as an extra column shown in a console

Bit of context... In my project I have one embedded for loop that outputs data whereby for each category show the item and within each item show its property so in reality the output I generated is 3 columns of data in the console (headings:…
Zoe
  • 181
  • 1
  • 2
  • 11
-1
votes
1 answer

How to display with align?

for (int j = 0; j < numStu; j++) { System.out.println((j + 1) + "\t" + StudentName[j] + "\t\t\t" + (Marks[j]) + "\t" + Grade[j]); } This is the output display for above command. No. Name Marks Grade 1 ADRIAN TAN …
-1
votes
1 answer

java homework . out of bounds exception 73

I have a bit of homework. I can't seem to find the fault forgive my interpretation of the question asked, as I only started a few weeks ago with java. But here is the question and my solution so far. Write a method demoArray4 in which you: Declare…
Robert Ryan
  • 294
  • 4
  • 12
-1
votes
1 answer

How do i print a return ArrayList?

I have a method that generates and returns an ArrayList. How can i print the ArrayList from other classes? public ArrayList selectAllePrinters() { ArrayList printers = new ArrayList<>(); try { Connection con =…
user3190748
  • 55
  • 1
  • 4
-1
votes
5 answers

Issue with printing an array list

I'm currently using a for loop to print elements in a list. It works fine and prints all the lines, however, nothing prints after the for loop itself. For example: for(int i=0;i<=petlist.size();i++) { …
-1
votes
2 answers

System.out.println doesn't show package name

I am trying to get an application ID from an app. My final goal is getting push messages to it. But I can't figure out why my package name doesn't show up. Does someone have an solution for it? Or an example app where it is working on? This is my…
Drogon
  • 360
  • 1
  • 4
  • 18
-1
votes
4 answers

Declare decision structure inside of a System.out.println

So I am working on an assignment where I have to have a print method in a constructor that displays a distance. I also have to have three separate get methods depending on what the input is in the demo class. My question is that I am trying to write…
Josh
  • 13
  • 2
-1
votes
3 answers

How to get values from ArrayList

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class clsWarehouse { private static int iChoice; private int…
user2260906
  • 9
  • 1
  • 1
  • 1
-2
votes
0 answers

Why does Kotlin use `println` instead of `print`?

Despite Kotlin being more concise and readable than Java for beginners, I don't understand why the latest version of Kotlin still requires a main function and moreover a println method. I watched this video and realized that Java 21 doesn't require…
redbraces
  • 1
  • 1
-2
votes
1 answer

How can I print out a specific part of my JSON within a struct in Go?

I want to print out the first "row" of my JSON that is within a struct in Go. The JSON looks like [ { "id":"7", "username":"user", "subject":"subject", "message":"message" }, { "id":"6", …
-2
votes
1 answer

How to save your println debugs properly?

I normally spend a lot of time println debugging my programs to make sure they do what I believe. However, when I am done with the debugging there are a lot of unnecessary println's everywhere. Is there some way of not throwing this work away and…
Databogdan
  • 11
  • 3
-2
votes
2 answers

Purpose of empty System.out.println()

I have the following code public class Main { public static void main(String[] args) { for (int i = 1; i <= 4; i++) { for (int j = 1; j <= i; j++) { System.out.print("*"); } …
-2
votes
2 answers

Is there anyway to condense my current code so that it isn't one long line (without making separate lines)

I'm currently working on a project for a Java class where we have to print out our schedule. I've got my code to look the way I want the final code to be. We can only use one System.out.print() This is so we can practice using escape sequences.…
kcash
  • 1
-2
votes
2 answers

How to align numbers in Java

So i'd like to align the row that displays the tenth year with rest of the numbers. I've tried printf but it doesn't seem to work. I've looked at many posts already but everything seems to be roaming around printf with some string formats. If you…
-2
votes
3 answers

Why won't println() print two arguments?

I am new to learning java and have come across an error when trying to print two arguments with println(). I'm not sure I am using the correct terminology here so please correct me if not. The code I am trying to run is. …