21 to 30 String Programs
100 Java String Programming Questions 100 Java String Programming Questions 21 to 30 Java Programs 21//Write a program to compare two strings lexicographically. Show Answer class lexicographically { public static void main(String[] args) { String str1="apple"; String str2="Apple"; int comparedValue=(str1.compareTo(str2)); if(comparedValue>0){ System.out.println(str1+ " will comes after "+str2); } else if(comparedValue 22//Write a program to concatenate two strings. Show Answer public class StringConcatenation { public static void main(String[] args) { String str1 = "Hello"; String str2 = "World"; String result1 = str1 + " " + str2; System.out.println("Concatenated string: " + result1); String ...