Java Strings Introduction

Sort by

recency

|

1273 Discussions

|

  • + 0 comments

    java 15

    public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
             Scanner sc=new Scanner(System.in);
            String A=sc.next();
            String B=sc.next();
            int sum = A.length() + B.length();
            System.out.println(sum);
            System.out.println(A.compareTo(B) <=0 ? "No" : "Yes");
            String capA = String.valueOf(A.charAt(0)).toUpperCase() + A.substring(1);
            String capB = String.valueOf(B.charAt(0)).toUpperCase()+ B.substring(1);
          
            System.out.println(capA.join(" ", capA, capB));
        }
    
  • + 0 comments

    Here is Java Strings Introduction solution - https://programmingoneonone.com/hackerrank-java-strings-introduction-problem-solution.html

  • + 0 comments

    This is a great intro to working with strings in Java—simple yet effective for grasping core string operations. Raja567 com Login

  • + 0 comments
    import java.io.*;
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            
            Scanner sc=new Scanner(System.in);
            String A=sc.next();
            String B=sc.next();
            
            // 1. Print the sum of the lengths
            int sum = A.length() + B.length();
            System.out.println(sum);
    
            // 2. Print whether A is lexicographically larger than B
            System.out.println(A.compareTo(B) > 0 ? "Yes" : "No");
    
            // 3. Capitalize and print
            String a = A.substring(0, 1).toUpperCase() + A.substring(1);
            String b = B.substring(0, 1).toUpperCase() + B.substring(1);
            System.out.println(a + " " + b);
            }
    }
    
  • + 0 comments

    Great breakdown of Java Strings and a nice little exercise to reinforce key concepts! Betbricks7 phone number