What is thread in Java.

Thread is a program in execution. All Java programs have at least one thread, known as the main thread, which is created by the JVM at the program’s start, when the main() method is invoked with the main thread. In Java, creating a thread is accomplished by implementing an interface and extending a class. Every […]

What is Java Bean with Example

Java Bean : Java bean is a class which contains all the properties are private and contains getter/setter methods corresponding to that. A public non-argument constructor is present in it. It implements Serializable interface which have no methods defined in it. Bean is basically used for serialization of data and maintain its state during transfer. […]

What is regex in Java and How to use it.

Java Regex : Java Regex and regular expression is an API which define pattern for searching or manipulating strings. It provides following classes and interface for regular expression. (i)   MatcherResult Interface (ii)  Matcher class (iii) Pattern class (iv)  PatternSyntaxExeption class Matcher class implements MatcherResult Interface which contains following methods. (i) boolean matches() : test […]

Regex Character Classes with example

Regex Character Classes : [abc] : a,b or c characters only [^abc] : Any character except a, b or c character. [a-zA-Z] : a through z or A through Z, inclusive range. [a-d[m-p]] : a through d or m through p [a-z&&[def]] : d, e or f intersection. [a-z&&[^bc]] : a through z except b […]

String class methods

List of methods which present in String class. 1. char charAt(int index) return character from the specified index position. 2. int compareTo(Object o) Compare string with another object. 3. int compareTo(String anotherString) Compare two strings and return integer output 1 means first string is greater than second string,  -1 means first string is less than second string, […]