This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to compare two strings lexicographically | |
* using compareTo() library function. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class CompareLexicographically { | |
public static void main(String[] args) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The Java program to compare two strings lexicographically | |
* by creating user defined function. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class CompareLexicographicallyWithUserDefinedFunction { | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to reverse a string. | |
* We are using 'charAt()' method of the String class to get all char and arrange it in | |
* descending order to get a reverse string. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class ReverseString { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to reverse a string. | |
* | |
* We are using 'getByets()' method of the String class to get byte array of the specified string | |
* and assign it to the another byte array of the same length in the descending order. | |
* | |
* New String object of the reversed byte array will give reversed string. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to reverse a string. | |
* | |
* We are using 'toCharArray' method of the String class to get char array of the specified string | |
* and append it with the temp string in reverse order. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class ReverseStringUsingToCharArray { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to reverse a string. | |
* | |
* We are using 'reverse()' method of the StringBuilder class. This method rverse the | |
* character sequence represented by the string. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class ReverseStringUsingReverseMethodOfStringBuilder { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to reverse a string. | |
* | |
* We are using 'reverse()' method of the Collections. This method reverse the | |
* order of elements of the list specified. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
import java.util.ArrayList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to compare strings using == operator. | |
* | |
* == operator ckecks weather both the strings referring | |
* to the same String Object. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class CompareUsingEqualsToOperator { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Java program to compare strings using compareTo() | |
* and compareToIgnoreCase() method. | |
* | |
* compareTo() compare strings lexicograpgically. | |
* | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class CompareUsingCompareTo { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A java program to use an intern() method of the String class. | |
* | |
* intern() method returns the canonical representation of the string. | |
* @author Gaurav Kukade at coderolls.com | |
*/ | |
public class UseInternMethod { | |
public static void main(String[] args) { |
OlderNewer