Hash code in Java is very important specially with the introduction of the Java Collections API. Many classes in the Collections API uses hash code as a convention. So what exactly is a hash code? It is an integer representation of a specific Object instance. The assumption is that this integer value should be the same whenever the hashCode() method is invoked on the same Object more than once during an execution of a Java application. The hashCode method must consistently provide the same value provided that no internal data used in equals is modified on the Object. We should not worry about this on Immutable objects as internal data is not change throughout it's lifetime. In addition, if two objects are equal using the equals method of the class, then the hashCode of both should return the same value. This implies that the hashCode should be based on the data used in equals method. Lastly, it is not required that two unequal Objects should have different hashCode. Since hashCode is common to all classes as it is implemented in the Object class, we will discuss on how it is implemented in the String class of Java. This post will explain and give examples on Java String HashCode.
The trend in the software development industry is going in the direction of making things easier and simpler. This is why languages such as Groovy is getting popular as time pass by. And there has been a big surge in popularity of Groovy when Gradle became the recent standard in Build Automation System. Groovy is just hands down concise and simpler than Java and makes developer time so much more efficient. In this post, we will explore how to use Groovy Maps by providing examples for different use cases.
Groovy is now getting popular with the help of the increasing user base of Gradle. Groovy language is exceptional in being a very concise and powerful language. Compared to Java, writing things just needs very short code that is human friendly and makes developers happy. One common task we deal in most generic programming language is manipulating Strings and List. Below is an example on how to convert a Groovy List to String.
String is one of the most fundamental data structure. It is versatile and useful for many cases. This is why Strings are used in many cases instead of using more restrictive data structure. But sometimes we need to compare two or more Strings for specific programming needs. Below are som examples on how we can compare Strings in Java.
String is an all around data structure for saving information because it can handle arbitrary sequence of characters. Often times, it is also used to store numeric, date, or other type of information. Sometimes we need to convert a String object to another data structure. For example, if an HTML form submits a date information to the server, each data in the form are passed as String. In this case, we would need to convert the String to Date such that other computations can be performed. For example, determining the age based on birth date and current date. Below are some ways on how we could convert a String into Date for some specific condition or method.
String is just a staple of most programming languages. It represents a sequence of characters into one data structure. It is a very convenient way to store many types of things in memory or in the database. An array on the other hand is one of the most simple way to represent multiple values. It is simpler that Classes such as List or Set because it can also be found in older programming language such as C/C++ or Pascal. It is only natural that we sometimes want to convert a String into an array of Characters for easier manipulation later. Below are some ways on how we can Convert a String to Char Array in Java .
Object is the root class of all classes in Java. Every class that we use or declare in Java has Object as a super class when traced to the top. All objects, including primitive wrappers, implements the method of the Object class. Array on the other hand is a convenient data structure for holding multiple values with the same class or interface. This post will discuss some caveats about Java Array Of Objects.
Strings and Arrays are two of the most popular data type in Java and in other popular language. String are able to represent a series of characters that is viewed as a single entity. While arrays are used to hold multiple values in the most simple way. But how do we convert a String like "One,Two,Three" into an array splitting into 3 different words or string? Below are some examples on in Java on how to split String into Array.
Array is the most basic way to represent a group of data with unknown size. Collections has been popular in recent years but arrays will always have a good use case because of it's simplicity. But before we could use an array, we should now how to create an instance. Below are some examples on how we can create array in Java.
Programmers usually want to use arrays because it can hold arbitrary number of items, depending on how we created the array object. Most of the things we wish to do with arrays, like searching or sorting, needs us to know it's size. Because we usually manipulate arrays using loop, we need to know the size of an array to know how many times we need to loop. We will show how to find Java Array Size and give some examples on how to use it.