Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java 8 support interpolation [duplicate]

Groovy supports string interpolation operations. Here is an example

def name = "Tom"
println("Hello my name is ${name}")

Does Java 8 support string interpolation as the way Groovy does?

Any answer, greatly appreciated. Thanks

like image 550
Dan Smith Avatar asked Aug 15 '26 12:08

Dan Smith


1 Answers

Java8 has nothing to do with this. For formatted console output, you can use printf() or the format() method of System.out Try this out.

System.out.printf("My name is: %s%n", "Tom");
like image 147
Ravindra Ranwala Avatar answered Aug 18 '26 01:08

Ravindra Ranwala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!