- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maruthi Krishna has Published 951 Articles
Maruthi Krishna
935 Views
The replaceAll() method of the String class accepts two strings, One representing a regular expression to find a string and the other representing a replacement string.And, replaces all the matched sequences with the given String. Therefore, to replace a particular word with another in a String −Get the required String.Invoke ... Read More
Maruthi Krishna
6K+ Views
The replaceAll() method accepts a regular expression and a String as parameters and, matches the contents of the current string with the given regular expression, in case of match, replaces the matched elements with the String.To delete a particular String from a file using the replaceAll() method −Retrieve the contents ... Read More
Maruthi Krishna
5K+ Views
Using a character arrayGet the both strings, suppose we have a string str1 and the string to be added at begin of str1 is str2.Create a character array with the sum of lengths of the two Strings as its length.Starting from 0th position fill each element in the array with ... Read More
Maruthi Krishna
775 Views
A resource is an object which implements AutoClosable interface. whenever you use a resource in your program it is recommended to close it after the usage.Initially, this task is done using the finally block.Exampleimport java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Scanner; public class FinalExample { public static void main(String[] ... Read More
Maruthi Krishna
94 Views
A String is a class in Java which stores a sequence of characters, it belongs to the java.lang package. Once you create a String object you cannot modify them (immutable).StorageAll String objects are stored in a separate memory location in the heap area known as, String Constant pool.Whenever you define ... Read More
Maruthi Krishna
626 Views
While a superclass method throws an exception while overriding it you need to follow the certain rules.Should throw Same exception or, sub typeIf the super-class method throws certain exception, the method in the sub-class should throw the same exception or its sub type.ExampleIn the following example, the readFile() method of ... Read More
Maruthi Krishna
631 Views
The split() method of the String class accepts a delimiter (in the form of the string), divides the current String into smaller strings based on the delimiter and returns the resulting strings as an array. If the String does not contain the specified delimiter this method returns an array which ... Read More
Maruthi Krishna
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 ... Read More
Maruthi Krishna
482 Views
The split() method of the String class accepts a delimiter (in the form of the string), divides the current String into smaller strings based on the delimiter and returns the resulting strings as an array. If the String does not contain the specified delimiter this method returns an array which ... Read More
Maruthi Krishna
138 Views
In Java you can read the contents of a file in several ways one way is to read it to a string using the java.util.Scanner class, to do so, Instantiate the Scanner class, with the path of the file to be read, as a parameter to its constructor.Create an empty ... Read More