Java Strings Introduction

  • + 0 comments

    Solution code :-

    import java.io.*;
    import java.util.*;
    
    public class Solution {
        public static String capitalize(String str){
            StringBuilder capitalize = new StringBuilder();
            char firstChar = str.charAt(0);
    				capitalize.append(Character.toTitleCase(firstChar)).append(str.substring(1));
            return capitalize.toString();
        }
    
        public static void main(String[] args) {
            
            Scanner sc = new Scanner(System.in);
            String A=sc.next();
            String B=sc.next();
            sc.close();
            System.out.println(A.length() + B.length());
            if(A.charAt(0)>B.charAt(0)) System.out.println("Yes");
            else System.out.println("No");
            System.out.println(capitalize(A) + " " + capitalize(B));
        }
    }