Java : String - Exercises and Solution


1. Write a Java program to concatenate Two strings

View Solution

2. Write a Java program to get the character at the given index within the String

View Solution

3. Write a Java program to get the character (Unicode code point) at the given index within the String

View Solution

4. Write a Java program to count a number of Unicode code points in the specified text range of a String

View Solution

5. Write a Java program to compare two strings lexicographically Two strings are lexicographically equal if they are the same length and contain the same characters in the same positions

View Solution

6. Write a Java program to compare two strings lexicographically , ignoring case differences

View Solution

7. Write a Java program to concatenate a given string to the end of another string

View Solution

8. Write a Java program to test if a given string contains the specified sequence of char values

View Solution

9. Write a Java program to compare a given string to the specified character sequence

View Solution

10. Write a Java program to compare a given string to the specified string buffer

View Solution

11. Write a Java program to check whether a given string ends with the contents of another string

View Solution

12. Write a Java program to check whether two String objects contain the same data

View Solution

13. Write a Java program to get the contents of a given string as a byte array

View Solution

14. Write a Java program to get the canonical representation of the string object

View Solution

15. Write a Java program to create a character array containing the contents of a string

View Solution

16. Write a Java program to convert all the characters in a string to Lowercase

View Solution

17. Write a Java program to convert all the characters in a string to Uppercas

View Solution

18. Write a java program to get the length of a given string

View Solution

19. Write a Java program to replace a specified character with another character

View Solution

20. Write a Java program to replace each substring of a given string that matches the given regular expression with the given replacement

View Solution

21. Write a Java program to check whether a given string starts with the contents of another string

View Solution

22. Write a Java program to get a substring of a given string between two specified positions

View Solution

23. Write a Java program to trim any leading or trailing whitespace from a given string

View Solution

24. Write a Java program to create a new string repeating every character twice of a given string

View Solution

25. Write a Java program to return the sum of the digits present in the given string. If there is no digits the sum return is 0

View Solution

26. Write a Java program to Count words in Given String

View Solution

27. Write a Java program to Swap Two Strings

View Solution

28. Write a Java program to Swap Two Strings without Third String Variable

View Solution

29. Write a Java program to Reverse Each Word of a String

View Solution

30. Write a Java program How to search a word inside a string?

View Solution

31. Write a Java program to find first non repeating character in a string

View Solution

32. Write a Java program to print after removing duplicates from a given string

View Solution

33. Write a Java program to find the maximum occurring character in a string

View Solution

34. Write a Java program to reverse words in a given string

View Solution

35. Write a Java program to find maximum between two string

View Solution

36. Write a Java program How to check Palindrome Strin

View Solution

37. Write a Java program to check if the letter 'x' is present in the word 'String Exercises'

View Solution

38. Write a Java program to Given string Convert Lowercase to Uppercase

View Solution

39. Write a Java program to Given string Convert Uppercase to Lowercase

View Solution

40. Write a Java program to Count Number of Uppercase and Lowercase letters

View Solution

41. Write a program to Trim a given string using String.trim() method

View Solution

42. Write a program to Replace string with another string in java using String.replace() method

View Solution

43. Write a program to Convert any type of value to string value using String.valueOf() method

View Solution

44. Write a program to String comparison using Collator and String classes

View Solution

45. Write a program to Compare the strings using equals(), compareTo() and == operator

View Solution

46. Write a program to First alphabet capital of each word in given string

View Solution

47. Write a program to Convert a character array to string

View Solution

48. Write a program to String concatenation with primitive data type values

View Solution

49. Write a program to Check given strings are Anagram or not

View Solution

50. Write a program to separate all tokens (words) using StringTokenizer

View Solution



Basic Programs