Skip to content

Instantly share code, notes, and snippets.

View gauravkukade's full-sized avatar

Gaurav Kukade gauravkukade

View GitHub Profile
@gauravkukade
gauravkukade / CompareLexicographically.java
Created August 7, 2019 09:55
A Java program to compare two strings lexicographically using compareTo() library function. It is embedded at https://coderolls.com/compare-two-strings-lexicographically-in-java
/**
* 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) {
@gauravkukade
gauravkukade / CompareLexicographicallyWithUserDefinedFunction.java
Created August 8, 2019 13:15
A Java program to compare two strings lexicographically by creating user defined function. It is embedded at https://coderolls.com/compare-two-strings-lexicographically-in-java
/**
* 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) {
@gauravkukade
gauravkukade / ReverseString.java
Created August 12, 2019 09:26
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. This program is embedded at https://coderolls.com/reverse-a-string-in-java
/**
* 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 {
@gauravkukade
gauravkukade / ReverseStringUsingGetBytes.java
Created August 12, 2019 10:58
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. The program is embedded at https://coderolls.com/reverse-a-s…
/**
* 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
*/
@gauravkukade
gauravkukade / ReverseStringUsingToCharArray.java
Created August 12, 2019 12:33
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. The program is embedded at https://coderolls.com/reverse-a-string-in-java
/**
* 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 {
@gauravkukade
gauravkukade / ReverseStringUsingReverseMethodOfStringBuilder.java
Created August 13, 2019 06:13
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. The program is embedded at https://coderolls.com/reverse-a-string-in-java
/**
* 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 {
@gauravkukade
gauravkukade / ReverseStringUsingReeverseMethodOfCollections.java
Created August 13, 2019 07:19
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. The program is embedded at https://coderolls.com/reverse-a-string-in-java
/**
* 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;
@gauravkukade
gauravkukade / CompareUsingEquals.java
Last active December 21, 2019 04:03
A Java program to compare two strings using equsls() and equalsIgnoreCase() method of the String. The code snippet is used in a blog at https://coderolls.com/comparing-strings-in-java
/**
* A Java program to compare two strings using equsls()
* and equalsIgnoreCase() method of the String.
*
* @author Gaurav Kukade at coderolls.com
*/
public class CompareUsingEquals {
public static void main(String[] args) {
@gauravkukade
gauravkukade / CompareUsingEqualsToOperator.java
Created August 21, 2019 11:02
A Java program to compare strings using == operator. == operator ckecks weather both the strings referring to the same String Object. The code snippet is used at https://coderolls.com/comparing-strings-in-java
/**
* 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 {
@gauravkukade
gauravkukade / CompareUsingCompareTo.java
Created August 21, 2019 11:07
A Java program to compare strings using compareTo() and compareToIgnoreCase() method. compareTo() compare strings lexicograpgically. The code snippet is used at https://coderolls.com/comparing-strings-in-java
/**
* A Java program to compare strings using compareTo()
* and compareToIgnoreCase() method.
*
* compareTo() compare strings lexicograpgically.
*
* @author Gaurav Kukade at coderolls.com
*/
public class CompareUsingCompareTo {