int x = 21;
String y = "Sample text";
System.out.printf("%s | x = %d
", y, x);
You Can Use System.out.printf("%d",n) also for formatting in java
// Here is an example from https://docs.oracle.com/javase/tutorial/java/data/numberformat.html
System.out.format("The value of " + "the float variable is " +
"%f, while the value of the " + "integer variable is %d, " +
"and the string is %s", floatVar, intVar, stringVar);