سٹرنگ کی لمبائی کتنی ہے؟
جاوا میں سٹرنگ کی لمبائی کیسے معلوم کی جائے؟
جاوا کسی بھی سٹرنگ کی لمبائی کا حساب لگانے کے لیے ایک آسان اور آسان طریقہ فراہم کرتا ہے ۔ مزید اڈو کے بغیر، آئیے اسٹرنگ کی لمبائی تلاش کرنے کی ایک مثال دیکھیں۔مثال
public class StringLength {
public static void main(String args[]) {
String alphabetsWithSpaces = "A B C";
String digitsWithSpaces = "1 2 3";
String specialCharsWithSpaces = "! @ $";
String allChars = "Z X 3 $$$ ^^^ * )(";
String sentence = "Hey, it's finally summers!";
System.out.println(alphabetsWithSpaces + " length = " + alphabetsWithSpaces.length());
System.out.println(digitsWithSpaces + " length = " + digitsWithSpaces.length());
System.out.println(specialCharsWithSpaces + " length = " + specialCharsWithSpaces.length());
System.out.println(allChars + " length = " + allChars.length());
System.out.println(sentence + " length = " + sentence.length());
}
}
آؤٹ پٹ
ABC لمبائی = 5 1 2 3 لمبائی = 5 ! @ $ لمبائی = 5 ZX 3 $$$ ^^^ * )( لمبائی = 23 ارے، آخر میں گرمیاں ہیں! لمبائی = 26
GO TO FULL VERSION