Lesson 23 of 34

StringBuilder: வேகமாக String உருவாக்குதல்StringBuilder: Building Strings Fast

8 min 30 XP

String immutable என்பதால் loop-ல் += செய்தால் ஒவ்வொரு முறையும் புதிய String உருவாகும், மெதுவாக இருக்கும். StringBuilder மாற்றக்கூடியது, வேகமானது.

Because Strings are immutable, += in a loop creates a new String every time, which is slow. StringBuilder is mutable and fast. String vs StringBuilder is a common interview question.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

split() ஒரு String-ஐ பிரித்து String array தரும். String.join() மீண்டும் இணைக்கும்.

split() breaks a String into a String array and String.join() puts pieces back together.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Challenge

+30 XP

ஒரு வாக்கியத்தைப் படித்து, சொற்களின் வரிசையைத் தலைகீழாக்கி print செய்யுங்கள். Input: I love Java Output: Java love I

Read a sentence and print its words in reverse order. Input: I love Java Output: Java love I

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.