skip to Main Content

I’ve just started learning Java from Head First. I’m on Ubuntu 22.04.2 LTS and coding in text editor.

I have no issue compiling and running a program in the terminal, my problem is that System.out.println() works whereas System.out.print() doesn’t show anything on the command-line.

I did sudo apt-get update and upgrade but it didn’t fixes my issue, unfortunately.

public class DooBee {
    public static void main (String[] args) {
        int x = 1;
        while (x < 3) {
            System.out.print("Doo");
            System.out.print("Bee");
            x = x + 1;
        }
        if (x == 3) {
            System.out.print("Do");
        }
    }
}
    

2

Answers


  1. Chosen as BEST ANSWER

    I think I just didn't see it beforehand or maybe rebooting helped, but now it's there, lol. Thanks for the lightning fast answers regardless!!


  2. [![Plese refer Here][1]][1]

    I tried to inspect your code it works fine in online compiler. please check any online compilers
    [1]: https://phpout.com/wp-content/uploads/2023/05/0sc5u.png

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search