
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

4K+ Views
In this tutorial, we will learn how to find out if the first character of a String is a digit in Java. Following are the different ways to do so: Using the isDigit() method. Using the regular expressions. Using the charAt() and isDigit() methods. Using the isDigit() method The isDigit() method of the java.lang.Character class accepts a character as a parameter and determines whether it is a digit or not. If the given character is a digit, this method returns true otherwise, this method returns false. Therefore, to determine whether the first character of the given ... Read More

13K+ Views
We can read the contents of a web page in several ways using Java. Here, we are going to discuss three of them. Those are as follows: Using the java.net.URL class. Using the HttpClient library. Using the org.jsoup library. Using the URL class The URL class of the java.net package represents a Uniform Resource Locator which is used to point a resource (file or, directory or a reference) in the world wide web. The openStream() method of this class opens a connection to the URL represented by the current object and returns an InputStream object using which you ... Read More

4K+ Views
The java.util.regex package of java provides various classes to find particular patterns in character sequences. The pattern class of this package is a compiled representation of a regular expression. To match a regular expression with a String this class provides two methods namely − compile() − This method accepts a string representing a regular expression and returns an object of the Pattern object. matcher() − This method accepts a String value and creates a matcher object which matches the given String to the pattern represented by the current pattern object. Following is the regular expression to match date in dd-MM-yyyy format − ^(1[0-2]|0[1-9])/(3[01]|[12][0-9]|0[1-9])/[0-9]{4}$ Therefore, to validate ... Read More

18K+ Views
In this article, we will learn how to convert a string to hexadecimal and hexadecimal to string in Java. Hexadecimal is a base-16 number system that uses 16 symbols to represent a number. Those symbols can be 0-9 and A-F letters. String to Hexadecimal in Java To convert a string to hexadecimal in Java, we can use the toHexString() method of the Integer class accepts an integer as a parameter and returns a hexadecimal string. Following are the steps to convert a string to hexadecimal: Get the desired String. Create an empty StringBuffer object. Convert it into a ... Read More

14K+ Views
Strings are used to store a sequence of characters in Java, they are treated as objects. The String class of the java.lang package represents a String.You can create a String either by using the new keyword (like any other object) or, by assigning value to the literal (like any other primitive datatype).String stringObject = new String("Hello how are you"); String stringLiteral = "Welcome to Tutorialspoint";Concatenating StringsYou can concatenate Strings in Java in the following ways −Using the "+" operator − Java Provides a concatenation operator using this, you can directly add two String literalsExampleimport java.util.Scanner; public class StringExample { ... Read More

252 Views
We can use the method below to read the contents of a file in Java: Using the java.util.Scanner class. Using the java.io.BufferedReader class. Using the java.nio.file.Files class. Using the Scanner class In Java, you can read the contents of a file in several ways. One way is to read it into a string using the java.util.Scanner class, to do so, follow the steps below: Instantiate the Scanner class, with the path of the file to be read, as a parameter to its constructor. Create an empty String buffer. Start a while loop with a condition, if the ... Read More

665 Views
In this article, we will learn how to split a string on a fixed character sequence in Java. We have multiple ways to split a string in Java. Some of them are as follows: Using the split() method of the String class. Using the substring() method of the String class. Using the StringTokenizer class. Let's discuss each of them in detail one by one. Using the split() method of the String class The split() method of the String class accepts a delimiter (in the form of a string), divides the current String into smaller strings based on the ... Read More

169 Views
Since Java8 StringJoiner class is introduced this you can construct a sequence of characters separated by desired delimiter.Sr.NoConstructor & Description1StringJoiner(CharSequence delimiter)This constructor creates an empty (no characters) StringJoiner, just with a copy of the specified delimiter.2StringJoiner(CharSequence delimiter, CharSequence prefix, CharSequence suffix)This constructs a StringJoiner without characters.Methods of StringJoiner classadd() − This method accepts a CharacterSequence object (Segment, String, StringBuffer, StringBuilder) and adds it to the current Joiner separating the next and previous elements (if any) with delimiter at the time of constructing it.Exampleimport java.util.StringJoiner; public class StringJoinerExample { public static void main(String args[]) { StringJoiner joiner ... Read More

17K+ Views
In this article, we will learn how to find a unique character in a string in Java. A unique character is a character that occurs only once in the string, while all others can occur multiple times. We can solve this problem using the following ways: Using Brute Force method. Using HashMap. Using brute force method To find a unique character in a given string, we will use a brute force approach. In the brute force approach, we will use two loops to compare each character to the rest of the string. Let's look at the steps: ... Read More

2K+ Views
In this article, we will learn to extract all the words that start with a vowel and have a length equal to n from a given text file or string in Java. We can solve this problem using the following ways: Using the split() method of the String class. Using the StringTokenizer class. Using Regular Expressions. Using the split() method of the String class To extract all the words that start with a vowel and have a length equal to n from a given text file or string in Java, we can use the following steps: The ... Read More