Lesson 5 of 34

Strings ഉപയോഗിച്ചുള്ള പ്രവർത്തനം

9 min 20 XP

Strings-നൊപ്പം ധാരാളം ഉപയോഗപ്രദമായ methods വരുന്നു. length() നീളം നൽകുന്നു. charAt(i) സ്ഥാനം i-ലെ അക്ഷരം നൽകുന്നു, എണ്ണം 0 മുതൽ. substring(a, b) a മുതൽ b വരെയുള്ള ഭാഗം നൽകുന്നു (b ഉൾപ്പെടാതെ).

Example: edit me and press Run

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

Strings ഒരിക്കലും == കൊണ്ട് താരതമ്യം ചെയ്യരുത്; equals() ഉപയോഗിക്കൂ. Capital letters നോക്കാതെ താരതമ്യം ചെയ്യാൻ equalsIgnoreCase(). ഇത് interview-ലെ പ്രിയപ്പെട്ട ചോദ്യമാണ്!

Example: edit me and press Run

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

Strings immutable ആണ്: toUpperCase() പോലുള്ള methods പുതിയ String തിരികെ നൽകുന്നു, യഥാർത്ഥത്തെ മാറ്റുന്നില്ല.

Challenge

+20 XP

ഒരു വാക്ക് വായിച്ച് അതിന്റെ ആദ്യ അക്ഷരം, അവസാന അക്ഷരം, നീളം എന്നിവ print ചെയ്യൂ. Input: Chennai Output: First: C Last: i Length: 7

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