Java has introduced various types of operators to perform different kinds of operations which we need to do in our implementations. Unary operators are one of them that requires only one operand to operate. We can use unary operators for several operations such as increment, decrement, negation, etc. Let’s see one by one.
Unary plus operator (+)
“+” operator can be used to indicate positive values. When “+” is written before any operand, that value becomes positive. However, any number has a positive value by default in java.
Unary minus operator (-)
“-” operator returns the negative value of…
Before java 8, software developers have to use anonymous classes or separate classes to implement interfaces with one abstract method which is called functional interfaces. Also, it had to write a bunch of code lines to iterate over java collections. But the headache continued, only until java 8 introduced the concept of lambda expressions. Let’s see how to use lambda expressions to make our code more efficient with less coding.
What is a Lambda Expression
A lambda expression is a block of code that can take arguments and return values. It works as a method but has no name…
A Regular expression alias a Regex is simply a sequence of characters that we can use to identify a pattern. Learning how to write a regular expression is much worth in software development because it can be used for both day-to-day validations as well as identifying search patterns in coding. Well, let’s learn the concepts.
Basic Character Symbols & Patterns
First of all, we have to know what kind of characters we have to use for identifying patterns. The below table describes mostly used symbols in regular expressions.
Other than character symbols and patterns we discussed…
What is a String
Well, String is the data type that we usually use for storing an immutable sequence of characters, simply a non-modifiable character array. A String is not a primitive variable type but a java class. The compiler creates objects of the String class when we use a string literal in our code. String literal means variable value inside double-quotes. Also, we can implement strings simply by creating String objects with the “new” keyword.
As a novel java programmer it is very important to understand how to compare two Strings. The String class has several methods for comparing…
As a java programmer, we all have to face coding errors called bugs during both compile-time and runtime. We all have more or fewer mistakes in our codes but it is always easier to identify compile-time issues than runtime ones. On the other hand, it is always worth letting the compiler know about memory allocation and validation of variables for better type safety. Well, Java 5 introduced their solution, Generics alias parameterized types.
Using Generics with Collections
We use java collections to handle data structures and implement logic related to them. But using Generics we can implement our data…
Learning object oriented concepts is a must for a software developer. It is very easy to understand when you are able to see everything in the world as objects. We live in an object oriented environment where we can clearly see connections between objects and we give names for each different connection. Let’s dive into the deep.
Object vs. Class
Basically, a class is just a template or blueprint. We need a class to create objects of that kind. As an example let us take a car model. It is simply a class. We need a car model to create…
One who work in software industry as well as loves writing. Trying to combine both for sharing knowledge all over the world.