Browse Source

docs(SortArgs) - Fix bug in ExerciseRunner (#2138)

Restores the default `System.out` to fix result printing

`System.out` was changed to a custom `printStream`, so `System.out.println(output.equals("1 2 3 4\n"));` printed `true` or `false` to this `printStream` and not the default `System.out`. This causes console output to be empty.
pull/2483/head
Maxim Mikhailov 8 months ago committed by GitHub
parent
commit
49d02bfdee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      subjects/java/piscine/SortArgs/README.md

5
subjects/java/piscine/SortArgs/README.md

@ -28,8 +28,13 @@ public class ExerciseRunner {
public static void main(String[] args) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(outputStream);
var defaultOut = System.out;
System.setOut(printStream);
SortArgs.sort(new String[]{"4", "2", "1", "3"});
System.setOut(defaultOut);
String output = outputStream.toString();
System.out.println(output.equals("1 2 3 4\n"));
}

Loading…
Cancel
Save