C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » Java programs

Java String Programs (Example of String Class in Java)

This section contains Java String Programs, examples on String Class. Here you will find programs to get length of the string, convert string into character array, trimming the string, splitting the string, example of startsWith and endsWith methods, replacing the string, reversing the string, example of isEmpty method, Example of String.compareTo method, example of String.subString method, example of String.toLowerCase method, example String.toUpperCase method, example of String.valueOf method etc.

Example of String Class Method and String Programs in Java

  1. Java program to make first alphabet capital of each word in a string.
    Here, we are implementing java program that will read a string and makes first alphabet capital of each word in given string.
  2. Java program to get the last index of any given character in a string.
    In this java program, we are getting the last index of any given character in a string? Here we are taking a string and character; we are printing its last index in string.
  3. Java program to concatenate two strings.
    In this java program, we are going to learn how to concatenate two strings? Here, we have two strings which will be entered through the user and we will concatenate them.
  4. Java program to reverse words of a string.
    In this java program, we are going to learn how to reverse words of a string? Here, we have a string and print string by changing the order of words.
  5. Java program to find occurrences of each character in a string.
    In this java program, we are going to learn how to find occurrences of each character in string? Here, we will read a string and print the total number of count of each character.
  6. Java program to separate all tokens (words) using StringTokenizer.
    In this java program, we are going to learn how to access all tokens (words) from a string using StringTokenizer() class?
  7. Java program to Encrypt/Decrypt String Using AES 128 bits Encryption Algorithm.
    This java program will read a string and encrypt the input string using AES 128 bits Encryption Algorithm, and also decrypt the Encrypted string using the same method.
  8. Java program to check given strings are Anagram or not.
    This java program will read two strings and check whether they are anagram strings or not.
  9. Java program to get string and count number of words in provided string.
    This java program will read a string and returns the total number of words in an input string; here we are counting the total number of words in a string.
  10. Easiest way to check Given String is Palindrome String or not in Java.
    This java program will read a string and check whether it is Palindrome or not using easiest method.
  11. Java program to input a string from user and reverse each word of given string.
    This java program will read a string through input device and reverse each word in given string. Let suppose the input is "Hello Welcome in India" program will print the "olleH emocleW ni aidnI".
  12. Java program to compare two strings using String.compareTo() method.
    String.CompareTo() method - Here, you will learn how to compare two strings in java using String.CompareTo() method which is a built-in method of String class.
  13. Java program to convert any type of value to string value using String.valueOf() method.
    String.valueOf() method - Here, you will learn how to convert any type of value like integer, float, etc to string using String.valueOf(), method which is a built-in method of String class.
  14. Java program to get sub string from a given string.
    Here, we will learn how to get sub string from a given string using String.substring() method in Java? This method returns sub string from given start to end index.
  15. Java program to convert string to lowercase and uppercase.
    Here, we will learn how to convert string into Lowercase and Uppercase using String.toLowerCase() and String.toUpperCase() methods in java.
  16. How to check whether a given string is empty or not in Java?
    Learn: How to check whether a given string is empty or not using a java program? In this program we will use String.isEmpty() method to check given string is empty or not?
  17. How to reverse a string in Java with and without using StringBuffer.reverse() method?
    In this program, there is an example in java where you will learn how to reverse a string with and without using StringBuffer.reverse() method?
  18. How to replace string with another string in java using String.replace() method?
    In this program, we will learn how to replace a string with another string using String.replace() method of String class in Java?
  19. Java program to demonstrate example of String.startsWith() and String.endsWith()?
    String.startsWith() and String.endsWith() methods of String class: Here, we will learn how to check whether a string starts with a substring or not and whether a string ends with a substring or not?
  20. How to spilt string in substrings using String.split() in Java?
    String.split() in Java: Here, we will learn how to split string in substrings separating by given delimiter in java?
  21. How to trim a given string using String.trim() method in Java?
    String.trim() method in Java: Here, we will learn how to trim a given string using String.trim() method in Java?
  22. How to calculate length of the string using String.length() method in Java?
    String.length() method in Java: Here, we will learn how to calculate/get the length of the string using String.length() in Java?
  23. How to convert a character array to string in Java?
    Learn: How to convert a given character array to string? Here we will take a character array and string object, and then character array will be converted and assigned to the string object.








COMMENTS