-
Notifications
You must be signed in to change notification settings - Fork 109
/
Count_LowerCase.java
40 lines (39 loc) · 1.01 KB
/
Count_LowerCase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Find number of lower case in a string
* AriJIt = 3
*/
import java.util.*;
public class Count_LowerCase {
public static void main(String[]args)
{
int count = 0;
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
for (int i = 0; i < s.length(); i++)
{
if(Character.isLowerCase(s.charAt(i)))
{
count++;
}
}
/* Alternative Method using array creation
-----------------------------------------------------
char[] arr;
arr = s.toCharArray();
// Other process to create character array
| ******************************************
| for(int i=0; i<s.length(); i++)
| {
| arr[i] = s.charAt(i);
| }
//
for(int i=0; i<arr.length;i++)
{
if(Character.isLowerCase(arr[i]))
{
count++;
}
}
*/
System.out.println(count);
}
}