[Python] How to make print of Python in Java?

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    I've been doing recent programs with Java, Python, and C lately while still learning Ruby and Swift, and I have been interested in making print functions in diffrent languages, like Python's print, Java's System.out.println, C's printf and C++'s cout.

    I wanna do some "Hello, (user)" program of Python like this:

    user = input("What is your name? ")
    print(f"Hello, {user}.")


    And make a program in Java with the same print function.

    public static void main {
    Scanner user;
    print("What is your name? ");
    user = new Scanner(System.in);
    // print("Hello, ", user, ".");
    print(f"Hello, {user}.")
    }


    I want to use the f format to add in variables in the print function instead of concatenation (the comment in the Java program). I don't know how to do it just yet except the previous form, so I still didn't have tries. Is the f format possible here? Can it only be recreated in a different language? Or do I have to not make the function at all?

    Continue reading...

Compartilhe esta Página