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 लौटाते हैं और मूल को नहीं बदलते।