JAVA-19

Q.19 . You are given a stingstr=”SDJInternationalCollege”.Perform the following operation on it

Solution  

public class StringOperations {
    public static void main(String[] args) {
        String str = "SDJInternationalCollege";

        // Find the length of the string
        int length = str.length();
        System.out.println("Length of the string: " + length);

        // Replace the character 'e' by 'E'
        String replacedStr = str.replace('e', 'E');
        System.out.println("String after replacing 'e' with 'E': " + replacedStr);

        // Convert all characters to uppercase
        String upperStr = str.toUpperCase();
        System.out.println("String in uppercase: " + upperStr);
    }
}

TRY IT YOURSELF

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.