
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 7442 Articles for Java

599 Views
In Java, formatted text refers to those text that has been processed and arranged according to a specific format. According to the article, we will use the printf() method to learn how to print the formatted text. Formatted Text using printf() Method In Java, to print the formatted output or text we have a printf() method. The printf() method allows us to format output to a java.io.PrintStream or java.io.PrintWriter. These classes also contain a method called format() which can produce the same results, so whatever we read here for the printf() method can also be applied to the format() method. ... Read More

2K+ Views
The given task is to find the number of days in a month of a particular year. To understand this, consider that if we can determine the maximum day value in a month, we can use that as the number of days in that month. To do this, we can use the GregorianCalendar class. It is a concrete subclass of the Calendar class, and it provides the standard calendar system used by most of the world. In Java, this GregorianCalendar can handle both the Gregorian calendar as well as Julian calendar. Following are the different ways to ... Read More

399 Views
In Java, both deepToString() and asList() methods are static methods of the Arrays class. An array is an object that holds a fixed number of values of a similar type in a contiguous memory location. The deepToString() Method In Java, the deepToString() method is used to convert a multi-dimensional array into a string. It checks if any element in the array is also an array; it will convert that inner array to a string as well. Syntax Following is the syntax of the Arrays.deepToString() method: public static String deepToString(Object[] a) Here, a: An array ... Read More

4K+ Views
This article will use an anonymous class to create a Thread in Java. An Anonymous class is a class that does not have a name. Thread in Java In Java, a Thread is a part of a program that can be executed independently. All Java programs have at least one thread, known as the main thread, which is created by the Java Virtual Machine (JVM), when the main() method is invoked. Creating a Thread by Using Anonymous Class In Java, the basic way to create a thread is to either extend the Thread class or implement the Runnable interface. However, we ... Read More

20K+ Views
A String is a final class in Java, and it is immutable, it means that we cannot change the object itself, but we can change the reference to the object. The HTML tags can be removed from a given string by using the following approaches: Using replaceAll() Method Using Pattern and Matcher Using replaceAll() Method We can remove the HTML tags from a given string by using the replaceAll() method. The replaceAll() method accepts two parameters: a "regular expression" and a "replacement string". It replaces all substrings that match the ... Read More

2K+ Views
To verify whether a given String contains only characters −Read the String.Convert all the characters in the given String to lower case using the toLower() method.Convert it into a character array using the toCharArray() method of the String class.Find whether every character in the array is in between a and z, if not, return false.ExampleFollowing Java program accepts a String from the user and displays whether it is valid or not.import java.util.Scanner; public class StringValidation{ public boolean validtaeString(String str) { str = str.toLowerCase(); char[] charArray = str.toCharArray(); for (int i ... Read More

772 Views
When an exception is cached in a catch block, you can re-throw it using the throw keyword (which is used to throw the exception objects).While re-throwing exceptions you can throw the same exception as it is with out adjusting it as −try { int result = (arr[a])/(arr[b]); System.out.println("Result of "+arr[a]+"/"+arr[b]+": "+result); }catch(ArithmeticException e) { throw e; }Or, wrap it within a new exception and throw it. When you wrap a cached exception within another exception and throw it, it is known as exception chaining or, exception wrapping, by doing this you can adjust your exception, throwing higher ... Read More

3K+ Views
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 worldwide web.This class provides various constructors one of them accepts a String parameter and constructs an object of the URL class. While passing URL to this method if you used an unknown protocol or haven’t specified any protocol this method throws a MalformedURLException.Similarly, the toURI() method of this class returns an URI object of the current URL. If the current URL is not properly formatted or, syntactically incorrect according to RFC 2396 this method throws ... Read More

6K+ Views
Strings in Java represents an array of characters. They are represented by the String class.Using compareTo() methodThe compareTo() method of the String class two Strings (char by char) it also accepts null values. This method returns an integer representing the result, if the value of the obtained integer is −0: Given two Strings are equal or, null.1 or less: The current String preceeds the argument.1 or more: The current String succeeds the argument.Exampleimport java.util.Scanner; public class CompringStrings { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter your first string ... Read More

54K+ Views
The Character class is a subclass of Object class and it wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char. We can check whether the given character in a string is a number/letter by - Using isDigit() method Using ASCII value comparison Using isDigit() Method To check whether a given character is a number or not, Java provides a method called isDigit(). This method is a static method of the Character class and determines whether ... Read More