Regular Expressions in Java

Java provides the java.util.regex package for pattern matching with regular expressions. Java regular expressions are very similar to the Perl programming language and very easy to learn. A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a… Read More »

How to Set Date and Time In Java?

Java provides the Date class available in java.util package, this class encapsulates the current date and time. The Date class supports two constructors as shown in the following table. Sr.No. Constructor & Description 1 Date( )This constructor initializes the object with the current date and time. 2 Date(long millisec)This constructor accepts an argument that equals the number of milliseconds… Read More »

Implement Arrays In Java

Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Instead of declaring individual variables, such as… Read More »

Strings Class

Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings. Creating Strings The most direct way to create a string is to write − String greeting = “Hello world!”; Whenever it… Read More »

Character Class

Normally, when we work with characters, we use primitive data types char. Example char ch = ‘a’; // Unicode for uppercase Greek omega character char uniChar = ‘\u039A’; // an array of chars char[] charArray ={ ‘a’, ‘b’, ‘c’, ‘d’, ‘e’ }; However in development, we come across situations where we need to use objects… Read More »

Numbers Classes in Java

Normally, when we work with Numbers, we use primitive data types such as byte, int, long, double, etc. Example int i = 5000; float gpa = 13.65f; double mask = 125; However, in development, we come across situations where we need to use objects instead of primitive data types. In order to achieve this, Java… Read More »

Decision Making Statement in Java

Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Following is the general form… Read More »

How to add Loops in Java?

There may be a situation when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows… Read More »

Basic Operators in Java

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups − Arithmetic Operators Relational Operators Bitwise Operators Logical Operators Assignment Operators Misc Operators The Arithmetic Operators Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra. The… Read More »

Modifier Types in Java

Modifiers are keywords that you add to those definitions to change their meanings. Java language has a wide variety of modifiers, including the following − Java Access Modifiers Non Access Modifiers To use a modifier, you include its keyword in the definition of a class, method, or variable. The modifier precedes the rest of the… Read More »