Questions tagged [system.out]

Predefined stream object attached to the standard output in Java console applications.

It's a static variable in Java's System class. This tag is intended for questions about Java applications that write to the standard output.

404 questions
-1
votes
2 answers

Why is the last line of my code not printing? Also, what's the simplest way for me to round numbers to 2 decimals?

When running my program, the last line displaying yearly gas expense is not showing... what have I done wrong? Also would like some help rounding figures to 2 decimal points... I tried implementing a few strategies but none of them worked. Any help…
Jay Cee
  • 1
  • 1
-1
votes
2 answers

Why system.out.println changes reflects without building jar?

I am using maven as a build tool and running some integration-test cases. I logged some statements in my test case using System.out.println() and did a mvn verify and even i didn't clean install/package the jar.The changes were reflecting for…
Anand Kadhi
  • 1,790
  • 4
  • 27
  • 40
-1
votes
2 answers

System.out.print() is not displaying everything I expect and is unexpectedly printing new lines

System.out.print() is not displaying everything in the output box and when I enter to many characters it automatically makes a new line. I am entering 645 characters and when I press enter it should give me the corresponding 215 characters. Should i…
Ineedhelp
  • 11
  • 4
-1
votes
6 answers

How to print this format

I want to print persons in this format where each person is in a column, and each person is delimited by a space or a tab, i.e. John Smith Male Male 01 02 How can I modify my toString() to print out in a nice format? Currently, each field…
ling
  • 1,555
  • 3
  • 18
  • 24
-1
votes
3 answers

How to get my program to start over when the user hits "y" on

So I've used System.out.print("Enter more test scores? (y/n): "); yet when I run it and all the scores are summarizes the user isn't given the chance to do it again here is my code. Do you guys think I may have put it in the wrong place. public…
Jat
  • 3
  • 5
-1
votes
3 answers

How do I convert the content of System.out.print to a String variable in java

I have this line of code: System.out.print(postalCodeIndex.findClosestBruteForce(latitude, longitude)); It returns output from a text file that was ran through an algorithm. For example the output is can be : "A0E 2Z0 Monkstown Newfoundland NL…
answerSeeker
  • 2,692
  • 4
  • 38
  • 76
-1
votes
1 answer

Lab 10.1: computer science assignment

In case I haven't already asked about this one, here are the instructions, as always: The int t contains an integer between 1 and 50 (inclusive). Write code that outputs the number in words and stores the result in the String inwords. For…
-1
votes
2 answers

Java controlf and escape sequences

I'm trying to skip a line using an escape sequence, my code looks like System.out.printf("Number of students: " + numberOfStudents "\n"); but I am getting an error which says "Syntax error on token ""\n"", delete this token" I get the same error…
-1
votes
1 answer

Java code needs a system.out.println statement to run

I wanted to know if anyone else experienced this problem. This one portion of code in my game relies on a system.out.println statement to work. without it, it won't function properly while(isladder){ t = Map.tiles[(int) (Player.x + 15 +…
36redsoxfan
  • 250
  • 2
  • 5
  • 15
-1
votes
1 answer

My .jar file is not executing

I have created a basic Noughts and Crosses game where it takes text input from the user to determine where the X/O will be placed (everything is printed on-screen using System.out) and it works fine within BlueJ, however when I create a .jar file it…
Aeolos
  • 11
  • 4
-1
votes
2 answers

checking java predefined methods

I'm just wondering on how would you check java codes like System.Out.println("hi"); it should check if the syntax is correct. I've used a java template in ANTLR, but I'm not quite sure that ANTLR provide checking predefined java methods. Is it…
marchemike
  • 3,179
  • 13
  • 53
  • 96
-2
votes
1 answer

in Java I am redirecting System.out to a ByteArrayOutputStream but it is not working - why?

I have the following class: class Bla { private static final Consumer OUTPUT = System.out::println; public void print() { printStuff(OUTPUT); } public void printStuff(Consumer consumer) { …
Shivani S
  • 17
  • 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
3 answers

How do I fix it to output what I want to output?

I recently started coding in Java, I just started a week ago. The previous post was deleted because I did not specify it enough, I am sorry for that. I've been having troubles with for, do and while statements, and how do I output the same results…
-2
votes
1 answer

How to read console output in maven surefire unit test

I am trying to test a method which has to print a specific string to System.out. I have used this answer to get this working with JUnit. This works fine with JUnit, but the tests are then run in a CI environment, by Maven surefire. The test then…
Vincent
  • 185
  • 1
  • 11