HTML DOM Input FileUpload Form Property

Sharon Christine
Updated on 30-Jul-2019 22:30:26

163 Views

The HTML DOM input FileUpload form property returns the reference of the form which enclose the file upload input button.SyntaxFollowing is the syntax −object.formExampleLet us see an example of input FileUpload form property − Live Demo    body{       text-align:center;       background-color:#363946;       color:#fff;    }    form{       margin:2.5rem auto;    }    button{       background-color:#db133a;       border:none;       cursor:pointer;       padding:8px 16px;       color:#fff;       border-radius:5px;       font-size:1.05rem;    }    .show{     ... Read More

HTML DOM Input Email ReadOnly Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

139 Views

The HTML DOM Input Email readOnly property sets/returns whether Input Email can be modified or not.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputEmailObject.readOnlySetting readOnlyto booleanValueinputEmailObject.readOnly = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailstrueIt defines that the input email field is readOnly.falseIt defines that the input email field is not readOnly and can be modified.ExampleLet us see an example of Input Email readOnly property − Live Demo Input Email readOnly    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: ... Read More

Print Prime Numbers with Prime Sum of Digits in an Array

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

662 Views

Given with an array of elements and the task is to print those numbers whose digit sum is also prime and return -1 is not such digit exists in an arrayInput: arr[]={2, 4, 3, 19, 25, 6, 11, 12, 18, 7} Output : 2, 3, 25, 11, 12, 7Here, the given output is generated as it contains those additive numbers whose sum is also prime like − 2, 3, 7 are prime but 25(2+5=7), 11(1+1=2), 12(1+2=3) are also prime whereas numbers like 19(1+9=10) are not prime.AlgorithmSTART Step 1 -> Take array of int with values Step 2 -> declare start ... Read More

Convert Stream to List in Java

Daniol Thomas
Updated on 30-Jul-2019 22:30:26

258 Views

Declare and initialize an Integer array:Integer[] arr = {50, 100, 150, 200, 300, 400, 500, 600, 700, 800, 1000};Now, create a stream with the above elements:Stream stream = Arrays.stream(arr);To convert the above stream to list, use Collectors.toList():stream.collect(Collectors.toList()The following is an example to convert Stream to List:Exampleimport java.util.Arrays; import java.util.stream.Collectors; import java.util.stream.Stream; public class Demo {    public static void main(String[] args) {       Integer[] arr = {50, 100, 150, 200, 300, 400, 500, 600, 700, 800, 1000};       Stream stream = Arrays.stream(arr);       System.out.println("Stream = "+stream.collect(Collectors.toList()));    } }OutputStream = [50, 100, 150, 200, 300, 400, 500, 600, 700, 800, 1000]

Subtraction of Corresponding Elements of Two Arrays in 8086

Smita Kapse
Updated on 30-Jul-2019 22:30:26

348 Views

In this program we will see how to subtract the contents of two different arrays.Problem StatementWrite 8086 Assembly language program to subtract the contents to corresponding elements which are stored in two different arraysDiscussionIn this example there are two different arrays. The arrays are stored at location 501 onwards and 601 onwards. The size of these two arrays are stored at offset location 500. We are taking the array size to initialize the counter, then by using loops we are subtracting the elements one by oneInputAddressData……5000450109502035030850406……60104602016030260403……Flow DiagramProgram    MOV SI,  500     ;Point Source index to 500     MOV CL,  [SI]    ;Load the ... Read More

Toggle Query in MongoDB

Smita Kapse
Updated on 30-Jul-2019 22:30:26

444 Views

You need to find the document and after that you need to use update to toggle query. Let us first create a collection with documents −> db.toggleDemo.insertOne({"CustomerName":"John Smith", "CustomerAge":28, "isMarried":true}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc7be138f9e6ff3eb0ce43b") } > db.toggleDemo.insertOne({"CustomerName":"David Miller", "CustomerAge":25, "isMarried":false}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cc7be2e8f9e6ff3eb0ce43c") }Following is the query to display all documents from a collection with the help of find() method −> db.toggleDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cc7be138f9e6ff3eb0ce43b"),    "CustomerName" : "John Smith",    "CustomerAge" : 28,    "isMarried" : true } {    "_id" : ObjectId("5cc7be2e8f9e6ff3eb0ce43c"),    "CustomerName" : "David Miller",    "CustomerAge" : 25, ... Read More

Get Node at Specified Index in JTree with Java

Anvi Jain
Updated on 30-Jul-2019 22:30:26

489 Views

To get the node at a specified index in a JTree, use the getChildAt() method. Here, we are finding the node at index 3 i.e. 4th node −node.getChildAt(3)The following is an example to get the node at a specified index in a JTree −Examplepackage my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Products");       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Clothing (Product1 - P66778)");       DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Accessories (Product2 ... Read More

Remove Leading and Trailing White Spaces from String in MongoDB

Smita Kapse
Updated on 30-Jul-2019 22:30:26

670 Views

For this, you need to write some code using forEach(). Let us first create a collection with documents −> db.removingWhiteSpaceDemo.insertOne({"Title":" Introduction to java "}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd66f387924bb85b3f4894c") }Following is the query to display all documents from a collection with the help of find() method −> db.removingWhiteSpaceDemo.find();This will produce the following output −{ "_id" : ObjectId("5cd66f387924bb85b3f4894c"), "Title" : " Introduction to java " }Following is the query to remove white spaces (leading and trailing) from string value −> db.removingWhiteSpaceDemo.find({}, {"Title": 1 }).forEach(function(myDocument) {    myDocument.Title = myDocument.Title.trim();    db.removingWhiteSpaceDemo.update(       { "_id": myDocument._id ... Read More

When to Write Your Own Assignment Operator in C++

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

491 Views

Here we will see when we need to create own assignment operator in C++. If a class do not have any pointers, then we do not need to create assignment operator and copy constructor. C++ compiler creates copy constructor and assignment operator for each class. If the operators are not sufficient, then we have to create our own assignment operator.Example Live Demo#include using namespace std; class MyClass { //no user defined assignment operator or copy constructor is present    int *ptr;    public:       MyClass (int x = 0) {          ptr = new int(x);       }    void setValue (int x) {       *ptr = x;    }    void print() {       cout

Iterate Values in an Enum in Java

Venkata Sai
Updated on 30-Jul-2019 22:30:26

17K+ Views

Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can iterate the contents of an enumeration using for loop, using forEach loop and, using java.util.stream.Using for loopYou can retrieve the contents of an enum using the values() method. This method returns an array containing all the values. Once you obtain the array you can iterate it using the for loop.ExampleFollowing java program iterates ... Read More

Advertisements