
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

177 Views
The provider for the signature object can be obtained using the method getProvider() in the class java.security.Signature.Let us now see an example −Exampleimport java.security.*; import java.util.*; public class Main { public static void main(String[] argv) { try { Signature signature = Signature.getInstance("SHA256withRSA"); Provider provider = signature.getProvider(); System.out.println("The Provider is: " + provider); } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } } }OutputThe Provider is: SunRsaSign version 11ExampleLet us now see another example −import ... Read More

418 Views
A class which contains the abstract keyword in its declaration is known as abstract class. Abstract classes may or may not contain abstract methods, i.e., methods without body. But, if a class has at least one abstract method, then the class must be declared abstract.If a class is declared abstract, it cannot be instantiated. To use an abstract class, you have to inherit it from another class, provide implementations to the abstract methods in it. If you inherit an abstract class, you have to provide implementations to all the abstract methods in it.Let us see a simple example −Exampleabstract class CricketLeague { abstract void ... Read More

766 Views
HashSet extends AbstractSet and implements the Set interface. It creates a collection that uses a hash table for storage.A hash table stores information by using a mechanism called hashing. In hashing, the informational content of a key is used to determine a unique value, called its hash code.To traverse through a HashSet, you can use the Iterator in Java. At first, create a HashSet with string values −HashSet hashSet = new HashSet(); hashSet.add("Jack"); hashSet.add("Tom"); hashSet.add("David"); hashSet.add("John"); hashSet.add("Steve");Now, traverse using Iterator −Iterator iterator = hashSet.iterator(); while(iterator.hasNext()){ System.out.println(iterator.next()); }Let us see a simple example wherein we have some HashSet elements and we ... Read More

694 Views
A signature object that can implement the required signature algorithm can be obtained using the method getInstance() in the class java.security.Signature.Let us now see an example −Exampleimport java.security.*; import java.util.*; public class Main { public static void main(String[] argv) { try { Signature signature = Signature.getInstance("SHA256withRSA"); String str = signature.toString(); System.out.println(str); } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } } }OutputSignature object: SHA256withRSALet us now see another example −Exampleimport java.security.*; import java.util.*; public ... Read More

208 Views
The name of the algorithm for the signature object can be obtained using the method getAlgorithm() in the class java.security.Signature.Let us now see an example −Exampleimport java.security.*; import java.util.*; public class Main { public static void main(String[] argv) { try { Signature signature = Signature.getInstance("SHA256withRSA"); String algorithm = signature.getAlgorithm(); System.out.println("The Algorithm = " + algorithm); } catch (NoSuchAlgorithmException e) { System.out.println("Error!! NoSuchAlgorithmException"); } } }OutputThe Algorithm = SHA256withRSALet us now see another example ... Read More

346 Views
The log functions in Java are part of java.lang.Math. The functions include log, log10, log1p. Let us see an example of each of these log functions −static double log(double a)The java.lang.Math.log(double a) returns the natural logarithm (base e) of a double value. Let us see an example −Exampleimport java.io.*; public class Main { public static void main(String args[]) { // get two double numbers double x = 60984.1; double y = -497.99; // get the natural logarithm for x System.out.println("Math.log(" + x + ")=" ... Read More

22K+ Views
To remove leading and trailing spaces in Java, use the trim() method. This method returns a copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.Let’s say the following is our string with leading and trailing spaces −String str = new String(" Jack Sparrow ");Now, let us trim the string −str.trim()Following is an example to remove the leading and trailing spaces in Java −Exampleimport java.io.*; public class Main { public static void main(String args[]) { String str = new String(" Jack Sparrow "); ... Read More

2K+ Views
The java.lang.Math class contains methods for trigonometric operations like cos(), sin(), tan(), tanh(), cosh(), atan(), etc.Let us work around some of these trigonometric functions in Java −static double asin(double a)The java.lang.Math.asin(double a) returns the arc sine of an angle, in the range of -pi/2 through pi/2.Let us now see an example −Exampleimport java.util.*; public class Main { public static void main(String args[]) { // get a variable x which is equal to PI/2 double x = Math.PI / 2; // convert x to radians x = Math.toRadians(x); ... Read More

2K+ Views
A Jackson API is a Java-based library, and it can be useful to convert Java objects to JSON and JSON to Java objects. A Jackson API is faster than other API, needs less memory, and is good for large objects. We can process a JSON in three different ways: Streaming API, Tree Model, and Data Binding. We can pretty print JSON using the writerWithDefaultPrettyPrinter() of the ObjectMapper class, which is a factory method for constructing an ObjectWriter that will serialize objects using the default pretty printer for indentation. In this article, we will learn how to pretty print JSON using the Jackson ... Read More

2K+ Views
JSON is a format that is used to exchange data between a server and a client. It is lightweight and easy to read and write. In Java, we can convert JSON to/from Map using various libraries. In this article, we will discuss how to convert JSON to/from Map using the Jackson library. The Jackson is a library for Java, and it has very powerful data binding capabilities and provides a framework to serialize custom java objects to JSON and deserialize JSON back to Java object. We can convert JSON to/from Map using readValue() and writeValueAsString() methods of com.fasterxml.jackson.databind.ObjectMapper class. To ... Read More