Lesson 5 of 34
Strings: எழுத்துகளுடன் வேலைWorking with Strings
9 min 20 XP
String-ல் பல பயனுள்ள methods உள்ளன. length() நீளத்தைத் தரும். charAt(i) i-வது எழுத்தைத் தரும், எண்ணிக்கை 0-லிருந்து தொடங்கும். substring(a, b) a முதல் b-க்கு முன் வரை உள்ள பகுதியைத் தரும்.
Strings come with many useful methods. length() gives the length. charAt(i) gives the character at position i, counting from 0. substring(a, b) gives the part from a up to (not including) b.
Example: edit me and press Run
Press Run to see the result here.இரண்டு String-களை ஒப்பிட == பயன்படுத்தக் கூடாது, equals() பயன்படுத்துங்கள். Capital/small பார்க்காமல் ஒப்பிட equalsIgnoreCase().
Never compare Strings with ==; use equals(). Use equalsIgnoreCase() to compare without caring about capital letters. This is a favourite interview question!
Example: edit me and press Run
Press Run to see the result here.String-களை மாற்ற முடியாது (immutable). toUpperCase() போன்ற methods புதிய String-ஐத் தருகின்றன, பழையது மாறாது.
Strings are immutable: methods like toUpperCase() return a new String and leave the original unchanged.