Java program to count words starting with capital letters in given line
Simple Java program to count words starting with capital letters in given line Code: import java.util.Scanner; class p83{public static void main(String args[]){ Scanner sc=new Scanner(System.in); String s; System.out.println("Enter a line:"); s=sc.nextLine(); int count=0; for(String str: s.split(" ")) { if(str.charAt(0)>=65 && str.charAt(0)<=90) { count++; } } System.out.println("total number of words start with capital letters are :"+count); }}