We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String A=sc.next();
String B=sc.next();
/* Enter your code here. Print output to STDOUT. */
// 1. Sum the lengths of A and B
System.out.println(A.length() + B.length());
// 2. Determine if A is lexicographically larger than B
String[] words = new String[] {A, B};
Arrays.sort(words);
if (words[0] == A) {
System.out.println("No");
} else {
System.out.println("Yes");
}
// 3. Capitalize the first letter in A and B and print them on a single line separeted by space
String ACapitalized = A.substring(0, 1).toUpperCase() + A.substring(1);
String BCapitalized = B.substring(0, 1).toUpperCase() + B.substring(1);
System.out.print(String.format("%s %s", ACapitalized, BCapitalized));
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Strings Introduction
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
}