Java program to format the text blocks strings using formatted() method
KW.java
class KW 
{
    @SuppressWarnings({ "preview", "removal" })
    public static void main(String[] args) 
    {
        String s1 = """
                account_no: %d
                name: %s
                city: %s
                amount: %.2f
                """.formatted(25622348989L,"James Moore","Phoenix",5000.002335);
        System.out.println(s1);
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW account_no: 25622348989 name: James Moore city: Phoenix amount: 5000.00 kodingwindow@kw:~$
What Next?
Java Inheritance
Advertisement