4 odpowiedzi
+ 2
I don't think there is some direct method available for this purpose. You must use some kind of loop to test that.
This is one way.
var s = "sololearn";
long charCount = s.chars()
.filter(c->c=='l')
.count();
System.out.print(charCount);
+ 6
array.length : length is a final variable applicable for arrays. With the help of length variable, we can obtain the size of the array.
string.length() : length() method is a final variable which is applicable for string objects. length() method returns the number of characters presents in the string.
https://www.geeksforgeeks.org/length-vs-length-java/
+ 2
s.length()
0
Hello I am asking the count of a single character in the string.