
I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
Search for a command to run...

I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
No comments yet. Be the first to comment.
Spring AI Tool Calling: From Chatbot to AI Agent with @Tool Your AI is smart. It knows an enormous amount. But it's frozen. It doesn't know what time it is right now. It doesn't know what's on your ca
Spring AI Advisors API Explained Series: Spring AI Complete Course — Lecture 4 of 12Reading Time: 8 minutesLevel: Intermediate Most developers stop at ChatClient. That is enough for demos. It is not
Working with Multiple AI Models in Spring AI Spring AI Complete Course — Lecture 3 of 12Previous: Lecture 2 — ChatClient API | Next: Lecture 4 — Advisors API In production AI applications, you rarel
Spring AI ChatClient API: The Fluent Heart of AI Integration Introduction If you've ever tried integrating AI models into a Java application, you know the pain. HTTP clients, API keys scattered everywhere, vendor-specific SDKs that never quite fit. W...
What is Spring AI? — Why Java Developers Need This in 2026 Every AI tutorial you see is in Python. LangChain, LlamaIndex, OpenAI SDK — all Python. But here's the uncomfortable truth: 80% of enterprise backends run Java. So who's building AI into thos...
Text block is a new feature added from Java 15. As per JEP 378
A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over the format when desired.
Before Java 15, it has not supported multiline text. It has been difficult and ugly to write XML, JSON, SQL as string literals, where multiline make more readable code. With Java 15 +, we can use triple " to define a multiline string. It makes code more readable and cleaner.
Let us compare multiline Strings before & after Java 15.
Look at the below example of an HTML document
String htmlWithoutTextBlock="<!DOCTYPE html>\n" +
"<html>\n" +
" <body>\n" +
" <p>This is java example of HTML text block with and without Text block.</p>\n" +
" </body>\n" +
"</html>";
String htmlWithTextBlock= """
<!DOCTYPE html>
<html>
<body>
<p>This is java example of HTML text block with and without Text block.</p>
</body>
</html>""";
The newer one with text block is more readable and easy to understand.
Text block supports String formatting as the String without text block. Let us look at another example with JSON.
System.out.println("Formatting Text Block ");
String superHero = """
{
"name":"%s",
"prefix":"%s",
"suffix":"%s",
"power":"%s"
}
""";
System.out.println(String.format(superHero, "Invisible Force",
"Captain", "Lightening", "Invisible"));
The output of the above code will be
Formatting Text Block
{
"name":"Invisible Force",
"prefix":"Captain",
"suffix":"Lightening",
"power":"Invisible"
}
There are chances you have a long line to be added in java file. Rather than putting in one line, you can use \ to break it in code but to be taken as a single long line.
System.out.println("Very Long String as a single line");
String veryLongString= """
Once up a time, there used to be java strings without text blocks,\
they were difficult to read and comprehend, \
then came java 15 and it changed the game""";
System.out.println(veryLongString);
The output of the above code will be as following, Do note that it's a single line and not three different lines. If you don't add \ at the list it will print as it's written in different lines.
Very Long String as a single line
Once up a time, there used to be java strings without text blocks,they were difficult to read and comprehend, then came java 15 and it changed the game