Vikyath Ram has Published 176 Answers

Use a character class in Java Regular Expressions

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

A character class is set of characters that are enclosed inside square brackets. The characters in a character class specify the characters that can match with a character in an input string for success. An example of a character class is [a-z] which denotes the alphabets a to z.A program ... Read More

Pattern.matches() method in Java Regular Expressions

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

The java.util.regex.Pattern.matches() method matches the regular expression and the given input. It has two parameters i.e. the regex and the input. It returns true if the regex and the input match and false otherwise.A program that demonstrates the method Pattern.matches() in Java regular expressions is given as follows:Example Live Demoimport java.util.regex.Pattern; ... Read More

Demonstrate the usage of the Pattern.split() method in Java

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

The specified input sequence can be split around a particular match for a pattern using the java.util.regex.Pattern.split() method. This method has a single parameter i.e. the input sequence to split and it returns the string array obtained by splitting the input sequence around a particular match for a pattern.A program ... Read More

Using Varargs with standard arguments in Java

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

A method with variable length arguments(Varargs) in Java can have zero or multiple arguments. Variable length arguments(Varargs) can also be used with standard arguments However they must be the last argument in the argument list. Moreover, there can only be one variable length argument in the method.A program that demonstrates ... Read More

Recursive fibonacci method in Java

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

The fibonacci series is a series in which each number is the sum of the previous two numbers. The number at a particular position in the fibonacci series can be obtained using a recursive method.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    public static ... Read More

A non-static initialization block in Java

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

Instance variables are initialized using initialization blocks. These blocks are executed when the class object is created and before the invocation of the class constructor. Also, it is not necessary to have initialization blocks in the class.A program that demonstrates a non-static initialization block in Java is given as follows:Example Live ... Read More

What is an Inner class in Java?

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

A nested class in Java is of two types i.e. Static nested class and Inner class. An inner class is a non-static nested class. Inner class is a security mechanism in Java as it can be private while normal classes cannot.A program that demonstrates an inner class is given as ... Read More

Deriving a Class in Java

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

A class can be derived from the base class in Java by using the extends keyword. This keyword is basically used to indicate that a new class is derived from the base class using inheritance. It can also be said that it is used to extend the functionality of the ... Read More

Variable in subclass hides the variable in the super class in Java

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

Sometimes the variable in the subclass may hide the variable in the super class. In that case, the parent class variable can be referred to using the super keyword in Java.A program that demonstrates this is given as follows:Example Live Democlass A {    char ch; } class B extends A ... Read More

Date validation using Java Regular Expressions

Vikyath Ram

Vikyath Ram

Updated on 30-Jul-2019 22:30:24

The date can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the date and the given input date and returns true if they match and false otherwise.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    public static void main(String args[]) ... Read More

Advertisements