Regular Expression "re*" Metacharacter in Java

Krishna Kasyap
Published on 18-Nov-2019 11:59:11
The subexpression/metacharacter “re*” matches 0 or more occurrences of the preceding expression.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "aabc*";       String input = "aabcabcaabcabbcaabcbcaabc";       Pattern p = Pattern.compile(regex); ... Read More

Explain Regular Expression "\A" Metacharacter in Java

Krishna Kasyap
Published on 18-Nov-2019 11:56:22
The subexpression/metacharacter “\A” matches the beginning of the entire string.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = "\\AHi";       String input = "Hi how are you welcome to Tutorialspoint";       ... Read More

When to use @ConstructorProperties annotation with Jackson in Java?

raja
Published on 18-Nov-2019 11:56:18
The @ConstructorProperties annotation is from java.beans package, used to deserialize JSON to java object via the annotated constructor. This annotation supports from Jackson 2.7 version onwards. The way this annotation works very simple, rather than annotating each parameter in the constructor, we can provide an array with the properties names ... Read More

Regular Expression "." (dot) Metacharacter in Java

Krishna Kasyap
Published on 18-Nov-2019 10:28:41
The subexpression/metacharacter “.” matches any single character except a newline.Example1import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatchesAll {    public static void main( String args[] ) {       String regex = ".";       String input = "Hi how are you welcome to Tutorialspoint";       Pattern ... Read More

Regular Expression "$" (dollar) Metacharacter in Java

Krishna Kasyap
Published on 18-Nov-2019 10:15:54
The subexpression/metacharacter “$” matches the end of a line.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class EndWith {    public static void main( String args[] ) {       String regex = "Tutorialspoint$";       String input = "Hi how are you welcome to Tutorialspoint";       Pattern ... Read More

Regular Expression "^" (caret) Metacharacter in Java

Krishna Kasyap
Published on 18-Nov-2019 10:10:47
The subexpression/metacharacter “^” matches the beginning of a line. If you use this in a regular expression, it matches the sentence succeeding it in the input string.Example 1import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main( String args[] ) {       String regex = ... Read More

How to add/insert additional property to JSON string using Gson in Java?

raja
Published on 18-Nov-2019 07:33:53
The com.google.gson.JSonElement class represents an element of Json. We can use the toJsonTree() method of Gson class to serialize an object's representation as a tree of JsonElements. We can add/ insert an additional property to JSON string by using the getAsJsonObject() method of JSonElement. This method returns to get the element as JsonObject.Syntaxpublic ... Read More

Difference between fail-fast and fail safe in Java

Mahesh Parahar
Published on 18-Nov-2019 07:31:16
Sr. No.KeyFail-FastFail-Safe1ExceptionAny changes in the collection, such as adding, removing and updating collection during a thread are iterating collection then Fail fast throw concurrent modification exception. The fail-safe collection doesn't throw exception. 2.Type of collectionArrayList and hashmap collection are the examples of fail-fast iterator CopyOnWrite and concurrent modification are the examples of a ... Read More

Difference between Application context and Beanfactory in Spring framework

Mahesh Parahar
Published on 18-Nov-2019 07:26:41
Spring framework provides two IOC container for managing, configuring and manipulating beans. One is BeanFactory and the other is Application Context. The application context interface extends BeanFactory to enhance the functionality of BeanFactory. In new Spring versions, BeanFactory is replaced with ApplicationContext. But still, BeanFactory exists for backward compatibility. Spring version 2.0 and ... Read More

Difference between volatile and transient in java

Mahesh Parahar
Published on 18-Nov-2019 07:23:31
A volatile keyword is used in a multithreading environment where two threads reading and writing the same variable simultaneously. The volatile keyword flushes the changes directly to the main memory instead of the CPU cache. On the other hand, the transient keyword is used during serialization. Fields that are marked as ... Read More
1 2 3 4 5 6 7 ... 2811 Next
Advertisements