Java String Examples

Comparing Strings (== operator) This section describes how two string references are compared. If two String variables point to the same object then these two variables are called references for the same object.

Java String Examples

Comparing Strings (== operator) This section describes how two string references are compared. If two String variables point to the same object then these two variables are called references for the same object.

Java String Examples

Java String Examples

     

  1. Comparing Strings (== operator)
    This section describes how two string references are compared. If two String variables point to the same object then these two variables are called references for the same object.

  2. Creation of StringBuffer
    In this section, you will learn how to create a string buffer. Here we have used the following StringBuffer Constructors.
      
  3. Reading File into a Byte Array
    In this section, you will learn how to make a file to be read into a byte array. Here we have used inputStream constructor to take file as a parameter.
     
  4. Java Count Vowels
    In this program you will learn how to count vowels in a String. Here you will be asked to enter a String of your own choice and then you will get the number of vowels from that String.

  5. Java Display File-Extension
    In this program you will learn how to display the file extension of the file. Here you will be asked to enter the file name and then you will get the extension of the file.

  6. Java Change File-Extension 
    In this program you will learn how to change the file extension of the file. Here you will be asked to enter the file name whose extension is to be changed and then you will get the file name with the changed extension.

  7. Java String Occurrence in a String
    In this program you will learn how to find the occurrence of a String in another String. Here we have already taken a String.

  8. String replaceFirst() Method
    In this program you will learn how to replace words in a text. We are going to use replaceFirst() method of String class in Java. The description of the code is given below for the usage of the method.

  9. String indexOf() Method
    In this section, you will get the detailed explanation about the indexOf() method of String class. We are going to use indexOf() method of String class in Java. 

  10. String sort() Method
    In this program you will learn how to sort words in a String. The sorting will be done in ascending order.
    We are going to use sort() method of String class in Java. The description of the code is given below for the usage of the method.

  11. String replaceAll() Method
    In this program you will learn how to replace all the words in a String.
    We are going to use replaceAll() method of String class in Java. The description of the code is given below for the usage of the method.

  12. String indexOf(int ch) 
    In this section, you will get the detailed explanation about the indexOf(int ch) method of String class. We are going to use indexOf(int ch) method of String class in Java. 

  13. String indexOf(int ch, int fromIndex) 
    In this section, you will get the detailed explanation about the indexOf(int ch, int fromIndex) method of String class. We are going to use indexOf(int ch, int fromIndex) method of String class in Java. 

  14. String indexOf(String str) 
    In this section, you will get the detailed explanation about the
    indexOf(String str) method of String class. We are going to use indexOf(String str) method of String class in Java.

  15. String indexOf(String str, int fromIndex) 
    In this section, you will get the detailed explanation about the
    indexOf(String str, int fromIndex) method of String class. We are going to use indexOf(String str, int fromIndex) method of String class in Java.

  16. String lastIndexOf(int ch)
    In this section, you will get the detailed explanation about the lastIndexOf(int ch) method of String class. We are going to use lastIndexOf(int ch) method of String class in Java.

  17. String lastIndexOf(String str) 
    In this section, you will get the detailed explanation about the
    lastIndexOf(String str) method of String class. We are going to use lastIndexOf(String str) method of String class in Java. 

  18. String lastIndexOf(String str, int fromIndex)
    In this section, you will get the detailed explanation about the lastindexOf(String str, int fromIndex) method of String class. We are going to use lastindexOf(String str, int fromIndex) method of String class in Java.  

  19. String lastIndexOf(int ch, int fromIndex)
    In this section, you will get the detailed explanation about the lastindexOf(int ch, int fromIndex) method of String class. We are going to use lastindexOf(int ch, int fromIndex) method of String class in Java.

  20. String regionMatches()
    In this section, you will get the detailed explanation about the regionMatches() method of String class. We are going to use regionMatches() method of String class in Java.

  21. String substring(int beginIndex)
    In this section, you will get the detailed explanation about the substring(int beginIndex) method of String class. We are going to use substring(int beginIndex) method of String class in Java.

  22. String substring(int beginIndex, int endIndex)
    In this section, you will get the detailed explanation about the substring(int beginIndex, int endIndex) method of String class. We are going to use substring(int beginIndex, int endIndex) method of String class in Java.

  23. String equalsIgnoreCase(String Str)
    In this section, you will get the detailed explanation about the equalsIgnoreCase(String Str) method of String class. We are going to use equalsIgnoreCase(String Str) method of String class in Java. 

  24. String Concat()
    In this section, you will get the detailed explanation about the
    Concat() method of String class. We are going to use Concat() method of String class in Java.

  25. String copyValueOf(char[] data, int offset, int count)
    In this section, you will get the detailed explanation about the copyValueOf(char[] data, int offset, int count) method of String class. We are going to use copyValueOf(char[] data, int offset, int count) method of String class in Java. 

  26. String getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
    In this section, you will get the detailed explanation about the getChars() method of String class. We are going to use getChars() method of String class in Java. 

  27. String intern()
    In this section, you will get the detailed explanation about the intern() method of String class. We are going to use intern() method of String class in Java. The description of the code is given below for the usage of the method.

  28. String Determining a Character's Unicode Block
    In this section, you will get the detailed explanation about the UnicodeBlock() method of String class. We are going to use UnicodeBlock() method of String class in Java. The description of the code is given below for the usage of the method.