Found 2616 Articles for Java

MatchResult start(int group) method in Java with examples.

Maruthi Krishna
Updated on 10-Jan-2020 10:27:43

43 Views

The java.util.regex.MatcheResult interface provides methods to retrieve the results of a match.You can get an object of this interface using the toMatchResult() method of the Matcher class. This method returns a MatchResult object which represents the match state of the current matcher.The end(int group) method of this interface accepts an integer representing a particular group and returns the offset before the first match occurred in the specified group.Example Live Demoimport java.util.Scanner; import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Example {    public static void main( String args[] ) {       String regex = "(.*)(\d+)(.*)";       //Reading input ... Read More

MatchResult start() method in Java with examples.

Maruthi Krishna
Updated on 10-Jan-2020 10:24:36

60 Views

The java.util.regex.MatcheResult interface provides methods to retrieve the results of a match.You can get an object of this interface using the toMatchResult() method of the Matcher class. This method returns a MatchResult object which represents the match state of the current matcher.The start() method of this interface returns the beginning index of the current match.Example Live Demoimport java.util.Scanner; import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; public class StartExample {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a String");       Scanner sc = new Scanner(System.in);       String input = ... Read More

Character class p{javaMirrored} Java regex.

Maruthi Krishna
Updated on 10-Jan-2020 10:20:10

300 Views

This character class \p{javaMirrored} matches upper case letters. This class matches the characters which returns true when passed as a parameter to the isMirrored() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = sc.nextLine();       //Regular expression       String regex = "[\p{javaMirrored}]";       //Compiling the regular expression       Pattern pattern = ... Read More

Character class p{javaWhitespace} Java regex in java.

Maruthi Krishna
Updated on 10-Jan-2020 10:09:24

323 Views

This character class \p{javaWhitespace} matches spaces. This class matches the characters which returns true when passed as a parameter to the isWhitespace() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = sc.nextLine();       //Regular expression       String regex = "[\p{javaWhitespace}]";       //Compiling the regular expression       Pattern pattern = Pattern.compile(regex);   ... Read More

Character class p{javaUpperCase} Java regex.

Maruthi Krishna
Updated on 10-Jan-2020 10:05:40

513 Views

This character class \p{javaUpperCase} matches upper case letters. This class matches the characters which returns true when passed as a parameter to the isUpperCase() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = sc.nextLine();       //Regular expression       String regex = "[\p{javaUpperCase}]";       //Compiling the regular expression       Pattern pattern = ... Read More

Difference between super() and this() in java Program

Mahesh Parahar
Updated on 25-Feb-2020 06:13:14

9K+ Views

Along with various other keywords Java also provides this and super as special keywords which primarily used to represent current instance of a class and it's super class respectively. With this similarity both these keywords have significant differences between them which are listed as below - Sr. No.Keythissuper1Represent and Referencethis keyword mainly represents the current instance of a class.On other hand super keyword represents the current instance of a parent class.2Interaction with class constructorthis keyword used to call default constructor of the same class.super keyword used to call default constructor of the parent class.3Method accessibilitythis keyword used to access methods of ... Read More

Difference between Traditional Collections and Concurrent Collections in java

Mahesh Parahar
Updated on 24-Feb-2020 11:17:20

782 Views

In Java as we know that Collections are one of most important concept which makes Java as a powerful language in itself. It is only support of collections in Java which make it to support any type of data in a convenient and efficient way along with possible CRUD operations over them.But on same phase when collections get exposed to the multi-threading its performance get somewhat degraded because of somewhere collections lack the support to multi-threading environment. To overcome this limitation Java introduces Concurrent Collections which not only overcome the multi-threading environment limitation but also enhances the Java to perform ... Read More

Character class p{javaLowerCase} Java regex.

Maruthi Krishna
Updated on 10-Jan-2020 09:59:42

387 Views

This character class \p{javaLowerCase} matches lower case letters. This class matches the characters which returns true when passed as a parameter to the isLowerCase() method of the java.lang.Character class.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexExample {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = sc.nextLine();       //Regular expression       String regex = "[\p{javaLowerCase}]";       //Compiling the regular expression       Pattern pattern = ... Read More

Posix character classes p{Space} Java regex.

Maruthi Krishna
Updated on 09-Jan-2020 10:43:03

360 Views

This class matches white space characters. i.e. \t, , \x, 0B, \f, \r.Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SpaceCharacters {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = sc.nextLine();       //Regular expression       String regex = "[\p{Space}]";       //Compiling the regular expression       Pattern pattern = Pattern.compile(regex);       //Retrieving the matcher object       Matcher matcher = pattern.matcher(input);   ... Read More

Posix character classes p{XDigit} Java regex.

Maruthi Krishna
Updated on 09-Jan-2020 10:38:16

233 Views

This class matches hexa-decimal characters i.e. [0-9a-fA-F].Example 1 Live Demoimport java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class SpaceCharacters {    public static void main(String args[]) {       //Reading String from user       System.out.println("Enter a string");       Scanner sc = new Scanner(System.in);       String input = sc.nextLine();       //Regular expression       String regex = "[\p{XDigit}]";       //Compiling the regular expression       Pattern pattern = Pattern.compile(regex);       //Retrieving the matcher object       Matcher matcher = pattern.matcher(input);       int count = 0; ... Read More

Advertisements