compare strings in java
Java
int str1.compareTo(String str2)// Java program to Compare two strings
// lexicographically
public class GFG {
public static void main(String args[])
{
String string1 = new String("Geeksforgeeks");
String string2 = new String("Practice");
String string3 = new String("Geeks");
String string4 = new String("Geeks");
String string5 = new String("geeks");
// Comparing for String 1 != String 2
System.out.println("Comparing " + string1 + " and " + string2
+ " : " + string1.equals(string2));
// Comparing for String 3 = String 4
System.out.println("Comparing " + string3 + " and " + string4
+ " : " + string3.equals(string4));
// Comparing for String 4 != String 5
System.out.println("Comparing " + string4 + " and " + string5
+ " : " + string4.equals(string5));
// Comparing for String 1 != String 4
System.out.println("Comparing " + string1 + " and " + string4
+ " : " + string1.equals(string4));
}
}
if (aName.equals(anotherName))
{
System.out.println(aName + " equals " + anotherName);
}
else
{
System.out.println(aName + " does not equal " +anotherName );
}
Also in Java:
- Title
- how to take space separated input in java
- Category
- Java
- Title
- Fab to CircularRevealFrameLayout example
- Category
- Java
- Title
- how to use for loop for array in java
- Category
- Java
- Title
- ujava saum of positive integers
- Category
- Java
- Title
- bukkit java connect player to another server in bungeecord
- Category
- Java
- Title
- system.out.println shortcut
- Category
- Java
- Title
- how to make a new arraylist java
- Category
- Java
- Title
- android how to split string
- Category
- Java
- Title
- Java for loop
- Category
- Java
- Title
- throwing exceptions java
- Category
- Java
- Title
- getcolor deprecated
- Category
- Java
- Title
- java delay
- Category
- Java
- Title
- java declare an int inside an if statement
- Category
- Java
- Title
- how to extract data from delimited text file in java
- Category
- Java
- Title
- create object of static class in java
- Category
- Java
- Title
- android create snackbar
- Category
- Java
- Title
- math minimum java
- Category
- Java
- Title
- list in java
- Category
- Java
- Title
- java jpa criteriabuilder in xample
- Category
- Java
- Title
- java remove first character from string
- Category
- Java
- Title
- how to create gravity in java
- Category
- Java
- Title
- primitive and non primitive data types in java
- Category
- Java
- Title
- how to draw a line in java
- Category
- Java
- Title
- basic java coding
- Category
- Java
- Title
- how to replace all of one character with nothing in java
- Category
- Java
- Title
- java create a set with values
- Category
- Java
- Title
- error attribute fabattached not found
- Category
- Java
- Title
- int to long java
- Category
- Java
- Title
- java sleep in code
- Category
- Java
- Title
- fibonacci sequence in java recursion
- Category
- Java
- Title
- iterate over map keys java
- Category
- Java
- Title
- how to convert string to double in android studio
- Category
- Java
- Title
- read a mail and its content in java mail api
- Category
- Java
- Title
- kotlin jsonobject get nested
- Category
- Java
- Title
- java observable
- Category
- Java
- Title
- how to check if an arraylist contains a value in java recursion
- Category
- Java
- Title
- java display message
- Category
- Java
- Title
- isSelfDivisor java
- Category
- Java
- Title
- how to create a 2d arraylist java
- Category
- Java
- Title
- java classes and methods
- Category
- Java
- Title
- boolean java.lang.String.equals(java.lang.Object)' on a null object reference
- Category
- Java
- Title
- java hashmap syntax
- Category
- Java
- Title
- working with buttons in applet java
- Category
- Java
- Title
- detect tv remote keys andoid studio
- Category
- Java
- Title
- java swing draw centered text
- Category
- Java
- Title
- int to string java
- Category
- Java
- Title
- find first non repeating character in a string
- Category
- Java
- Title
- java remove non numbers from string
- Category
- Java
- Title
- write file from a specific location in java
- Category
- Java
- Title
- parsedouble java
- Category
- Java
- Title
- vector in java
- Category
- Java
- Title
- java how to define a function
- Category
- Java
- Title
- jtable font size
- Category
- Java
- Title
- iterate trough linked list java
- Category
- Java
- Title
- binary search java
- Category
- Java
- Title
- java how to print a newline
- Category
- Java
- Title
- comparable on a generic class java
- Category
- Java
- Title
- java enum
- Category
- Java
- Title
- applicationcontext.xml
- Category
- Java
- Title
- java how to show an array
- Category
- Java
- Title
- java for each
- Category
- Java
- Title
- how do you concatenate an int with a string in java
- Category
- Java
- Title
- get method of a class which I only have string to
- Category
- Java
- Title
- create java windows application
- Category
- Java
- Title
- change the value in a hashtable java
- Category
- Java
- Title
- how to make a char uppercase in java
- Category
- Java
- Title
- java time code
- Category
- Java
- Title
- determine if a given binary tree is a valid bst
- Category
- Java
- Title
- java 8 hashmap example stackoverflow
- Category
- Java
- Title
- how to iterate hashmap java
- Category
- Java
- Title
- java convert a set to array
- Category
- Java
- Title
- how to convert string to array in java
- Category
- Java
- Title
- java get folder content
- Category
- Java
- Title
- java remove double spaces
- Category
- Java
- Title
- string to char in java
- Category
- Java
- Title
- How to chage font progrmatically
- Category
- Java
- Title
- how to remove a certain string in a arraylist java
- Category
- Java
- Title
- Building a maven EAR project and specifying the configuration of which projects to include, what is the element in the plugin configuration that contains Enterprise Java Bean Projects:
- Category
- Java
- Title
- initiralizing an arraylist java
- Category
- Java
- Title
- butterfly pattern program in java
- Category
- Java
- Title
- contains example in java
- Category
- Java
- Title
- java string contains char
- Category
- Java
- Title
- java loop hashmap
- Category
- Java
- Title
- java method to capitalize first letter
- Category
- Java
- Title
- sign flutter app android studio
- Category
- Java
- Title
- java 8 retrieve all list from object into single list and ignore duplicates
- Category
- Java
- Title
- how to find complement of a number in java
- Category
- Java
- Title
- java shortest if else statement
- Category
- Java
- Title
- how to create a circle in java
- Category
- Java
- Title
- logger in java
- Category
- Java
- Title
- java create folder
- Category
- Java
- Title
- find min in array java
- Category
- Java
- Title
- creating random color in java
- Category
- Java
- Title
- java logical operator
- Category
- Java
- Title
- Could not resolve project :app
- Category
- Java
- Title
- while loop java
- Category
- Java
- Title
- money value commas java
- Category
- Java
- Title
- date to string java
- Category
- Java
- Title
- spigot sounds
- Category
- Java
- Title
- read lines of file randomly java
- Category
- Java