In this article, we will explore the ternary operator ?(question mark) and :(colon) in Java, what is its purpose, and why do we use it? 1. What is a Ternary Operator? The operator ? : in Java, is a ternary operator. It uses to evaluate a boolean expression. It is also known as a conditional operator. It consists of three ...
Read More »Home »
What is a Constructor in Java
In this article, we are going to explore what is a constructor in Java, why it is used, how it is formed, what are the rules applied to create one, we will see different types of constructors, constructor chaining, and overloading. 1. What is a Constructor in Java? The constructor is a piece of code that runs whenever the compiler ...
Read More »How to Convert a String to Array in Java
In this example, we are going to learn how to convert a string into an array in Java. We are going to discuss three different methods to break a string into an array. Using substring() methodUsing toCharArray() methodUsing split() method 1. Using substring() method The string class provides substring() method to fetch part of a string. String class has two ...
Read More »