0
Hello...how do i count characters in the sentence...example i write in console with space or .?-() then it output us count
5 Answers
+ 1
It depends. If you need an algorithm, i'll to show you, but else you can use the length function.
Exemple:
String sentence = "Hello World";
int length = sentence.length();
Else, if you need an algorithm, call this function in your main and pass sentence in parameter. :)
public static int length(String str)
{
int i = 0;
str += '\n';
while(str.charAt(i) != '\n')
{
i++;
}
return i;
}
+ 1
Oops, it is a String. ;)
0
thank i'll try it
0
sorry i dont know str variables in lenght method
0
thank