-
/*Java String compare example.This Java String compare example describes how Java String is compared with anotherJava String object or Java Object.*/
public class JavaStringCompareExample{
public static void main(String args[]){
/*Java String class defines following methods to compare Java String object.1) int compareTo( String anotherString )compare two string based upon the unicode value of each character in the String.Returns negative int if first string is less than anotherReturns positive int if first string is grater than anotherReturns 0 if both strings are same.2) int compareTo( Object obj )Behaves exactly like compareTo ( String anotherString) if the argument objectis of type String, otherwise throws ClassCastException.3) int compareToIgnoreCase( String anotherString )Compares two strings ignoring the character case of the given String.*/
String str = “Hello World”;String anotherString = “hello world”;Object objStr = str;
/* compare two strings, case sensitive */System.out.println( str.compareTo(anotherString) );/* compare two strings, ignores character case */System.out.println( str.compareToIgnoreCase(anotherString) );/* compare string with object */System.out.println( str.compareTo(objStr) );
}
}
/*OUTPUT of the above given Java String compare Example would be :-3200*/
Friday, 13 April 2018
Popular Posts
-
In today's data-driven world, creating charts is no longer enough. Organizations need professionals who can transform raw numbers into...
-
In today's data-driven world, uncertainty is everywhere. Whether predicting stock market trends, analyzing medical trials, building ma...
-
Deep Learning has revolutionized Artificial Intelligence by enabling machines to recognize images, understand language, generate content, ...
-
Machine Learning has become one of the most transformative technologies of the 21st century, powering everything from recommendation syste...
-
Fundamentals of Data Visualization: A Primer on Making Informative and Compelling Figures (Free PDF)In the era of big data, the ability to communicate information visually has become just as important as collecting or analyzing data. Ever...
-
Introduction In the world of data science and analytics, having strong tools and a solid workflow can be far more important than revisitin...
-
Modern Artificial Intelligence and Machine Learning are built upon a deep mathematical foundation. While many practitioners learn to use f...
-
Introduction to Machine Learning – A Complete Guide to Statistical Learning, Optimization, Kernel Methods, Neural Networks, Generative Mod...
-
Modern data science is built on uncertainty. Whether predicting customer behavior, diagnosing diseases, forecasting financial markets, or ...
-
Introduction Programming becomes meaningful when you build something — not just read about syntax, but write programs that do things. This...
Categories
100 Python Programs for Beginner
(119)
AI
(328)
Android
(25)
AngularJS
(1)
Api
(7)
Assembly Language
(2)
aws
(31)
Azure
(12)
BI
(10)
Books
(318)
Bootcamp
(14)
C
(78)
C#
(12)
C++
(83)
cloud
(1)
Course
(87)
Coursera
(302)
Cybersecurity
(34)
data
(10)
Data Analysis
(43)
Data Analytics
(31)
data management
(16)
Data Science
(413)
Data Strucures
(18)
Deep Learning
(211)
Django
(16)
Downloads
(3)
edx
(21)
Engineering
(15)
Euron
(30)
Events
(7)
Excel
(24)
Finance
(13)
flask
(4)
flutter
(1)
FPL
(17)
Generative AI
(77)
Git
(12)
Google
(54)
Hadoop
(3)
HTML Quiz
(1)
HTML&CSS
(48)
IBM
(43)
IoT
(3)
IS
(25)
Java
(99)
Leet Code
(4)
Machine Learning
(371)
Meta
(24)
MICHIGAN
(5)
microsoft
(13)
Nvidia
(8)
Pandas
(15)
PHP
(20)
Projects
(34)
Python
(1353)
Python Coding Challenge
(1208)
Python Mathematics
(8)
Python Mistakes
(51)
Python Quiz
(588)
Python Tips
(97)
Questions
(3)
R
(72)
React
(7)
Scripting
(3)
security
(4)
Selenium Webdriver
(4)
Software
(21)
SQL
(54)
Udemy
(18)
UX Research
(1)
web application
(11)
Web development
(9)
web scraping
(3)

0 Comments:
Post a Comment