Java Signature getProvider() method with Examples

AmitDiwan
Updated on 23-Sep-2019 12:38:17

96 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

The abstract keyword in Java

AmitDiwan
Updated on 23-Sep-2019 12:35:35

206 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

Traverse through a HashSet in Java

AmitDiwan
Updated on 23-Sep-2019 12:33:48

597 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

Java Signature getInstance() method with Examples

AmitDiwan
Updated on 23-Sep-2019 12:31:24

401 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

Java Signature getAlgorithm() method with Examples

AmitDiwan
Updated on 23-Sep-2019 12:29:24

93 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

Log functions in Java

AmitDiwan
Updated on 23-Sep-2019 12:27:32

268 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

Trigonometric Functions in Java

AmitDiwan
Updated on 23-Sep-2019 12:23:14

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

C Program for Armstrong Numbers

Sunidhi Bansal
Updated on 23-Sep-2019 12:00:35

443 Views

We are given a task where we have to check a number n entered by the user, whether it’s Armstrong or not.An Armstrong number is when the sum of all the digits power by the number of digits or we can say order of digits n, is same as the digit.So below is a simple representation how to find the Armstrong number −Formula −wxyz…. = pow(w, n) +pow(x, n) + pow(y, n) + pow(z, n) + …..AlgorithmSTART Step 1-> Declare a function to find the value after power operation on the number    int power(int a, int b)     ... Read More

HTML DOM Style objectFit Property

AmitDiwan
Updated on 23-Sep-2019 11:56:33

44 Views

The HTML DOM Style objectFit property returns and modify how an image or video element in an HTML document should be resized to fit its container element.SyntaxFollowing is the syntax −1. Returning objectFitobject.objectFit2. Modifying objectFitobject.objectFit = “value”Here, value can be −ValueExplanationinitialIt set this property value to its default value.inheritIt inherits this property value from its parent element.noneIn it the content is not resized.fillIn it the content is sized to fill the element’s content box and if necessary the object will be stretched or squished to fit the content box.containIn it the content is scaled to maintain its aspect ratio while ... Read More

Program for Area Of Square in C++

Sunidhi Bansal
Updated on 23-Sep-2019 11:53:37

727 Views

We are given with a side of a rectangle and our task is to print the area of the square from that side.Square is 2-D plain figure which have 4 sides and forms 4 angles of 90degree each and all the sides are of equal shape. In other words we can say that the square is a form of rectangle with equal sides.Given below is representation of a square −The Area of square is Side x SideExampleInput: 6 Output: 36 As the side is 6 so the output is 6*6=36 Input: 12 Output: 144AlgorithmSTART    Step 1-> Declare a function ... Read More

Advertisements