In last couple of tutorials you have learned how to get all selected checkbox and radio buttons, and in this tutorial, you will learn how to enable/disable form elements using jQuery. A form element e.g. a textfield, radio buttons and checkbox, all represented using input tag can be enabled or disabled by adding an attribute called "disabled". It's similar to "checked" attribute we have seen for checkbox and radio buttons. If this attribute is not present then element is enable, but if this attribute is present then you can use disabled=true to disable the form element and disabled=false to enable the form elements as shown in our example.
Thursday, November 21, 2024
Thursday, November 14, 2024
How to Compare Two Strings Without Case Sensitivity in Java? Example
How to Compare Two Strings Without Case Sensitivity in Java
Java provides several ways to compare strings without taking case sensitivity into account. In this article, we'll explore different methods to perform case-insensitive string comparisons in Java.
Method | Use Case | Efficiency |
---|---|---|
equalsIgnoreCase() | Checking equality | High |
compareToIgnoreCase() | Ordering comparison | High |
String.CASE_INSENSITIVE_ORDER | Sorting collections | High |
equals() + toUpperCase() | Not recommended | Low |
1. Using equalsIgnoreCase()
The equalsIgnoreCase() method
This method is ideal for checking if two strings are equal without considering their case. It returns true if both strings contain the same characters, regardless of their case.
String str1 = "Hello";
String str2 = "hello";
boolean isEqual = str1.equalsIgnoreCase(str2); // Returns true
2. Using compareToIgnoreCase()
The compareToIgnoreCase() method
Use this method when you want to check which string is greater or smaller, or to find out their relative ordering in lexicographical or alphabetical order, without considering case.
String str1 = "Apple";
String str2 = "banana";
int result = str1.compareToIgnoreCase(str2); // Returns a negative value
3. Using String.CASE_INSENSITIVE_ORDER
The String.CASE_INSENSITIVE_ORDER comparator
This comparator is useful for sorting a list of strings in case-insensitive order.
List<String> fruits = Arrays.asList("Apple", "banana", "Cherry");
Collections.sort(fruits, String.CASE_INSENSITIVE_ORDER);
// Result: [Apple, banana, Cherry]
4. Using equals() + toUpperCase()
Combining equals() and toUpperCase()
This is a tricky way to compare two strings in Java in a case-insensitive manner. First, convert both strings to uppercase, then compare them using equals().
String str1 = "Hello";
String str2 = "hello";
boolean isEqual = str1.toUpperCase().equals(str2.toUpperCase()); // Returns true
Note: This method is not recommended as it creates new String objects, which can be inefficient for large-scale comparisons.
Conclusion
When comparing strings without case sensitivity in Java, it's generally best to use the built-in methods like equalsIgnoreCase()
for equality checks and compareToIgnoreCase()
for ordering comparisons.
These methods are optimized and provide clear, readable code. For sorting collections of strings, the String.CASE_INSENSITIVE_ORDER
comparator is an excellent choice.
Remember, all these methods compare strings in lexicographical order. Choose the method that best fits your specific use case to ensure efficient and accurate string comparisons in your Java applications.
Thursday, November 7, 2024
How to convert XML to JSON in Java? Example
Since XML and JSON are two popular data interchange formats, you will often need to convert one into other. For example, many SOAP web services returns XML response and if you are using Java and wants to convert that XML response to JSON, then you can use JSON library from https://json.org. It provides a class called XML.java, which provides static methods to convert an XML text into a JSONObject. It also support JSON to XML conversion, which will learn in second part of the article. In order to use this class, you can dowload JAR files from Maven Central repository, or you can add required dependency in your pom.xml file.
Thursday, October 31, 2024
How to convert JSON String to Java HashMap? Example
Suppose you have a JSON String, may be a web-service response and you want to create a Map out of it, where key should be the fields and value should be values of those fields e.g. if given JSON String is following :
{
"zip": "90210",
"city": "Beverly Hills"
"state": "CA"
"timeZone": "P"
}
then your HashMap should contain 4 mappings where keys are zip, city, state and timeZone, all of String type and corresponding values.
Thursday, October 24, 2024
What is Timer and TimerTask in Java – Tutorial Example
4 Reasons and Benefits of Using Multithreading in Java? Why Threads?
4 examples to convert Date to LocalDate in Java 8?
One of the challenge you will face while using new Java 8 Date and time API, JSR-310 in existing Java application is the conversion between java.util.Date and java.time.LocalDate and other classes. Even though library has everything you would expect, it doesn't have a direct conversion method between old Date and new LocalDate. There is a reason for it, eventhough java.util.Date says its a date its not, becuase its just a millisecond value since midnight at the start of 1970 GMT. It's equivalent to Instant class in new Java Date API and that's why you have a direct conversion method between Date and Instant in Java 8. Anyway, its not hard to convert a java.util.Date to java.time.LocalDate in Java 8, in fact there are multiple ways which we will explore in this tutorial.
Wednesday, October 23, 2024
Difference between ExecutorService.submit() and Executor.execute() methods in Java?
Difference between Process and Thread in Java - Example
How to use Exchanger for Inter thread communication in Java? Example Tutorial
What happens when you call Thread.run() instead of Thread.start() in Java? Trick Interview Question
How to Implement Thread in Java with Example
In my opinion, Thread is one of the most important features of the Java programming language which helped it to become the most popular programming language. I remember, when I first started learning Java in one of the programming classes in India how important Thread was a portrait and how much emphasis is given on a clear understanding of multi-threading. It’s still popular and one of most sought after skills in Java programmer because writing concurrent and multi-threaded applications in Java is challenging, despite Java providing excellent support at language level using synchronized and volatile keyword.
Educative Review - Is Grokking Modern System Design for Software Engineers and Managers worth it?
Udemy vs Educative Review? Which is better Website for Beginners?
Can You Learn Coding and Web Development in your 40s and 50s?
Monday, October 21, 2024
Review - Is Grokking the Machine Learning Interview on Educative Worth it in 2025?
Hello friends, we are here again today for another exciting topic to discuss. But, today we are not gonna discuss something which is related to Java or any other language or spring boot. Today we are gonna discuss something which is immensely practical and has the potential to land you very high-paying data science jobs. Today we are gonna review a course that focuses on Machine Learning! Machine Learning is very important when we are considering data science interviews! So what's the wait? Let's start! On Educative.io, there is a great course called Grokking the Machine Learning Interview. It couldn't have come at a better moment, with machine learning expected to be a $3.6 billion business by 2025.
Is Coursera and IBM's Full Stack Software Developer Professional Certificate worth it in 2025? Review
Hello guys, if you are looking for the best full-stack Software developer course or certification on Coursera or you want to join IBM's Full Stack Software Developer Professional Certificate program but are not sure whether it's right for you then you have come to the right place. In this article, we will review IBM Full Stack Software Developer certification on 3 important points, instructor reputation, Coursera structure, content quality, and people's review. This will help you to decide whether this course is right for you or not.
Review - Is Java Programming & Software Engineering Fundamentals Certification on Coursera worth it?
Top 10 Eclipse Plugins for Java and Spring Boot Developers
Top 10 Java 11 Certification Mock Tests and Practice Tests [4 Free OCPJP 11 Sample Questions]
Sunday, October 20, 2024
Top 5 Websites to Learn SQL Online for FREE - Best of Lot
Grokking The Java Interview - My First Book After 10 Years as Java Blogger
5 Projects You can do to learn iOS App Development in 2025
Coursera Review - Is the Meta Frontend and Backend Developer Certificates Worth It in 2025?
Is Google Data Analytics Professional Certificate Worth it in 2025? Coursera Review
Hello guys, if you want to become a Data Analyst in 2025 and looking for best online courses, guides, and tutorials to learn Data Analysis then you have come to the right place. In the past, I have shared best Data Analysis courses, Books, and 2025 Data Analyst RoadMap, and in this article, I will share one of the most popular Coursera course to learn Data Analytic, Google Data Analytics Professional Certificate. With more than 950,000 enrollments on Coursera this is one of the most popular Data Analytics course on Coursera and why not? Its created from Google itself. It's also well structured, up-to-date and you will learn all essential Data Analytics skills from Google experts.
Saturday, October 19, 2024
Review - Is 2025 Web Developer Bootcamp by Colt Steele on Udemy worth it?
Udemy's The Complete 2025 Web Development Bootcamp by Angela Yu Course Review
Udemy's The 2025 Complete Python Bootcamp From Zero to Hero in Python Review
Review - Is Deep Learning Certification By Andrew Ng on Coursera worth it? (2025)
Coursera's Google IT Automation with Python Certification Review - Is it worth it in 2025?
Udemy's The Data Science Course: Complete Data Science Bootcamp 2025 Review - Is it worth it?
Friday, October 18, 2024
Top 25 Skills Java Developers Should Learn in 2025 [UPDATED]
6 Tips to write Production Quality Code
Top 10 Multithreading and Concurrency Best Practices for Experienced Java Developers
Review - Is Coursera's Python for Everybody Specialization worth it in 2025? [Best Python Certification]
Top 10 Coursera Courses to Learn AWS, Google Cloud, Azure, and Cloud Computing in 2025 - Best of Lot
Top 10 Coursera Certifications for Data Science, Data Analysis, and Data Visualization in 2025 - Best of Lot
Thursday, October 17, 2024
Top 7 Free Git Courses for Programmers to Learn Online in 2025 - Best of Lot
Top 10 DevOps Courses for Experienced Programmers to Learn Online in 2025 - Best of Lot
Top 8 Courses to Crack AZ-900: Microsoft Azure Fundamentals Cloud Certification in 2025 - Best of Lot
Top 6 Course to Crack Azure Administrator Associate Certification Exam AZ-104 in 2025 - Best of Lot
Top 7 AWS Solution Architect Associate Certification Practice Test and SAA-C03 Exam Dumps in 2025
Wednesday, October 16, 2024
How to find Square root of integer in Java without using any Library? Interview Question
Problem : Given an integer i, find square root of it, without using Math.sqrt() method. Your method should return square root if given number is perfect square otherwise return floor(sqrt(x));
For example,
Input i = 16
Output : 4
Input i = 17
Output : 4
This is very interesting problem and asked both freshers and experienced programmers. I have seen this question on many companies including ANZ, Barclays, and Citibank.
How to print Floyd's Triangle in Java? Example Tutorial
How to Check if two Rectangles Overlap in Java? Collision Detection Solution and Example
Top 5 AWS Certified Cloud Practitioner Exam (CLF-C02) Practice Questions & Dumps in 2025
Top 5 Course to Crack Microsoft Azure Developer Associate Certification Exam AZ-204 in 2025 - Best of Lot
Top 5 Courses to Crack Azure Solutions Architect Expert Certification (AZ 305) Exam in 2025 [UPDATED]
Tuesday, October 15, 2024
Top 5 Courses to learn Quarkus and Micronaut for Java Programmers in 2025 - Best of Lot
Linux Command to Find how Long a process is Running in UNIX - Example
Difference between FileInputStream and FileReader in Java | InputStream vs Reader Example
Monday, October 14, 2024
4 Ways to Convert String to long in Java? Example Tutorial
How to Count Negative Numbers in a Sorted Matrix? [Solved] (Amazon Coding Question)
Top 7 Free Java Courses for Beginners to Learn Online in 2025 - Best of Lot
Top 5 Practice Tests for AWS Certified Developer Associate DVA-C02 Certification in 2025 - Best of Lot
Top 7 Data Science and Machine Learning Courses to Learn Online in 2025 - Best of Lot
Top 5 Course to Crack AWS Solution Architect Professional (SAP-C02) Certification Exam in 2025 - Best of Lot
Java Program to find factorial of number in Java - Example Tutorial
Sunday, October 13, 2024
Top 7 Spring MVC Online Courses for Beginners in 2025 - Best of Lot
Saturday, October 12, 2024
Top 6 Courses and Books to Learn Tailwind CSS for Beginners in 2025 - Best of Lot
Top 8 Courses to learn Pandas and Python Data Analysis for Beginners in 2025 - Best of Lot
Top 5 Java 8 Certifications Courses to Prepare OCAJP (1Z0-808) Exam Online in 2025
Top 5 Online Courses to Crack AWS Certified Developer Associate Exam (DVA-C02) in 2025 - Best of Lot
Top 5 Udemy Course to Crack AWS Certified DevOps Engineer Professional Exam DOP-C02 in 2025 - Best of Lot
Thursday, October 10, 2024
How to check if array is a binary heap in Java? [Solved]
Problem : You have given an array of integer, check if the given array represents a binary max-heap data structure. In max heap every node is greater than all of its descendants.
For example :
Input: array[] = {100, 25, 20, 17, 22, 12}
Output: true
The given array represents below tree
100
/ \
25 20
/ \ /
17 22 12
This binary tree follows max-heap property as every node is greater than all of its descendant.
Tuesday, October 8, 2024
Top 7 Books and Udemy Online Courses to Crack the PMP Certification Exam in 2025 - Best of Lot
Monday, October 7, 2024
Top 7 Udemy Courses for CompTIA A+ Certification in 2025 (with Practice Test) - Best of Lot
20 Best Coursera Professional Certificates for IT Professionals in 2025 [UPDATED]
Saturday, October 5, 2024
10 Code Review Checklist and Best practices in Java
Code Review and Unit testing are some of the best development practices I always recommend, strive for, and enforce as much as possible. Even just by doing code review and Junit test case always offer positive results it can be improved a lot by constantly learning from our mistakes, others mistakes and by observing how others are doing it. I always try to get my code review done by someone with more technical and domain experience so that I can capture any domain-specific scenarios which have been missed during think through the process.