This program checks if a given string contains an uppercase letter and returns the first uppercase letter found. Here's how it works:
import java.io.*; class UpperCase_Letter { public static void main(String args[]) { String str = "tutor Joes"; char res = firstUppercaseLetter(str,0); if (res == 0) { System.out.println("No Uppercase Letter in a String"); } else { System.out.println (res); } } static char firstUppercaseLetter(String str, int i) { if(str.charAt(i)=='\0') { return 0; } if(Character.isUpperCase(str.charAt(i))) { return str.charAt(i); } try { return firstUppercaseLetter(str, i + 1); } catch(Exception e) { System.out.println("Exception Occurs"); } return 0; } }
J
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions