Reference to a Constructor Using Method References in Java 8

Maruthi Krishna
Updated on 08-Apr-2020 14:09:28

825 Views

Lambda expressions In Java allows you to pass functionality as an argument to a method. You can also call an existing method using lambda expressions.list.forEach(n -> System.out.println(n));Method references are simple, easy-to-read lambda expressions to call/refer and the existing method by name in a lambda expression. In addition to the instance and static methods, you can also refer a constructor by using the new keyword.SyntaxFollowing is the syntax to reference a constructor in Java.ClassName::newExampleinterface myInterface{    Test greet(String data); } class Test{    Test(String data){          System.out.println(data);    } } public class MethodReferences {    public static void ... Read More

Convert Colored Image to Blue, Green, Red Image Using Java OpenCV

Maruthi Krishna
Updated on 08-Apr-2020 14:06:04

425 Views

The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −src − A Matrix object representing source.dst − A Matrix object representing the destination.code − An integer value representing the color of the destination image.To convert a colored image to grayscale you need to pass Imgproc.COLOR_RGB2BGR as the third parameter to this method.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class ColorToGrayscale {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );   ... Read More

Convert Colored Image to Grayscale Using Java OpenCV Library

Maruthi Krishna
Updated on 08-Apr-2020 14:03:11

2K+ Views

The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −src − A Matrix object representing source.dst − A Matrix object representing the destination.code − An integer value representing the color of the destination image.To convert a colored image to grayscale you need to pass Imgproc.COLOR_RGB2GRAY as the third parameter to this method.Exampleimport org.opencv.core.Core; import org.opencv.core.Mat; import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; public class ColorToGrayscale {    public static void main(String args[]) throws Exception {       //Loading the OpenCV core library       System.loadLibrary( Core.NATIVE_LIBRARY_NAME );   ... Read More

Read Colored Image as Grey Scale Using Java OpenCV Library

Maruthi Krishna
Updated on 08-Apr-2020 14:00:57

387 Views

The imread() method of the Imgcodecs class accepts a string value representing a file name as a parameter. This method reads the contents of the specified file into a matrix object and returns it. Using this method you can read the contents of an image.In addition to this, the Imgcodecs class also provides another variant of this method which accepts an integer value representing a flag specifying the required reading mode.The following are the various fields of the Imgcodecs class that can be used as flag values.IMREAD_COLOR − If the flag is set to this value, the loaded image will be ... Read More

Write an Image Using Java OpenCV Library

Maruthi Krishna
Updated on 08-Apr-2020 13:53:05

773 Views

Using the OpenCV library you can perform image processing operations such as image filtering, geometrical image transformations, color space conversion, histograms, etc.Writing an imageWhenever you read the contents of an image using the imread() method of the Imgcodecs class the result is read into the Matrix object.You can write/save an image using the imwrite() method. This accepts two parameters namely −File − A string value representing the file path to which the result should be stored.Img − A matrix object containing the data of the image to be saved.ExampleThe following Java example reads the contents of the image cat.jpg as a ... Read More

What is an Unnamed Module in Java 9

raja
Updated on 08-Apr-2020 11:52:20

1K+ Views

An unnamed module is a concept of the unnamed package. It is a module in which packages or classes can't be defined in any named module but exist in the jar file from classpath. If our code can try to load type from those files, the module system attempts to lookup classpath and loads it.An unnamed module read all other modules, including all of the named,  built-in platform modules, and also exports all of its packages. The package in an unnamed module can be ignored, which is also defined in the named module.The unnamed module has access to:All packages exported by all other modules available in module-path.All the jars ... Read More

Create Full Screen Search Box with CSS and JavaScript

AmitDiwan
Updated on 08-Apr-2020 11:08:47

646 Views

Following is the code to create a full screen search box with CSS and JavaScript −Example Live Demo body {    font-family: Arial; } * {    box-sizing: border-box; } .showBtn {    background: #008b0c;    border: none;    color:white;    padding: 10px 15px;    font-size: 20px;    cursor: pointer;    opacity: 0.8; } .showBtn:hover {    opacity: 1; } .overlaySearch {    height: 100%;    width: 100%;    display: none;    position: fixed;    z-index: 1;    top: 0;    left: 0;    background-color: rgba(132, 150, 155, 0.747); } .searchBar {    position: relative;    top: ... Read More

Get Complete Drive Information Using C#

Samual Sam
Updated on 08-Apr-2020 09:33:56

267 Views

Drive information of an Operating System includes.Drive Name Volume Label Free Space Total Size Drive Format Drive TypeTo get above information about a drive, try to run the following code −Exampleusing System.IO; using System; class Program {    static void Main() {       DriveInfo driveInfo = new DriveInfo("D");       Console.WriteLine(driveInfo.Name);       Console.WriteLine(driveInfo.VolumeLabel);       Console.WriteLine(driveInfo.AvailableFreeSpace);       Console.WriteLine(driveInfo.TotalFreeSpace);       Console.WriteLine(driveInfo.TotalSize);       Console.WriteLine(driveInfo.DriveFormat);       Console.WriteLine(driveInfo.DriveType);    } }OutputThe following is the output −D: NTFS 76767677788 76767677788 45463434799 NTFS FixedNote − The output may vary with different Operating Systems.

Create a Form with Icons Using CSS

AmitDiwan
Updated on 08-Apr-2020 09:31:29

770 Views

Following is the code to create a form with icons −Example Live Demo body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } * {    box-sizing: border-box; } h1 {    text-align: center; } form {    max-width: 500px;    margin: auto; } .fieldContainer {    display: flex;    width: 100%;    margin-bottom: 15px; } .icon {    font-size: 30px;    padding: 10px;    background: rgb(11, 9, 116);    color: white;    min-width: 50px;    text-align: center; } .field {    font-size: 20px;    width: 100%;    padding: 10px;    outline: none; } .field:focus {    border: 2px solid dodgerblue; } .btn {    font-size: 24px;    background-color: rgb(20, 60, 170);    color: white;    padding: 15px 20px;    border: none;    cursor: pointer;    width: 100%;    opacity: 0.9;    border-radius: 8px; } .btn:hover {    opacity: 1; } Register Form Example Register OutputThis will produce the following output −

Create a Contact Form with CSS

AmitDiwan
Updated on 08-Apr-2020 09:20:49

512 Views

Following is the code to create a contact form using CSS −Example Live Demo * {box-sizing: border-box;} body{    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } label{    font-size: 15px; } input[type=text],textarea {    width: 100%;    padding: 12px;    border: 1px solid #ccc;    border-radius: 4px;    box-sizing: border-box;    margin-top: 6px;    margin-bottom: 16px; } input[type=submit] {    background-color: #4CAF50;    color: white;    padding: 12px 20px;    border: none;    border-radius: 4px;    cursor: pointer; } input[type=submit]:hover {    background-color: #45a049; } form {    border-radius: 5px;    background-color: #feffc6;    padding: 20px; } Contact Form First Name Last Name Email Id Contact OutputThis will produce the following output −

Advertisements