The HTML DOM previousElementSibling property returns the previous element in the same tree level of the specified element in an HTML document.SyntaxFollowing is the syntax −node.previousElementSiblingExampleLet us see an example of previousElementSibling property − Live Demo html{ height:100%; } body{ text-align:center; color:#fff; background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat; height:100%; } p{ font-weight:700; font-size:1.2rem; } .drop-down{ width:50%; border:2px solid #fff; ... Read More
Here we will see what are the differences between static_cast and normal C style cast.The normal cast like (int)x is C style typecasting where static_cast(x) is used in C++.This static_cast() gives compile time checking facility, but the C style casting does not support that. This static_cast() can be spotted anywhere inside a C++ code. And using this C++ cast the intensions are conveyed much better.In C like cast sometimes we can cast some type pointer to point some other type data.Like one integer pointer can also point character type data, as they are quite similar, only difference is character has ... Read More
Here, we are activating a frame. For deactivation, we have used dispose −Thread.sleep(2000); frame.setVisible(false);The frame first activates and then deactivates after 2 seconds since we have set sleep to 2000 miliseconds.The following is an example to activate and deactivate JFrame −Exampleimport java.awt.Frame; import javax.swing.JFrame; import javax.swing.JLabel; public class SwingDemo { public static void main(String[] args) throws InterruptedException { JFrame frame = new JFrame(); frame.add(new JLabel("Demo")); frame.pack(); frame.setVisible(true); Thread.sleep(2000); frame.setState(Frame.ICONIFIED); Thread.sleep(2000); frame.setVisible(false); frame.dispose(); ... Read More
Asset Size: 32dp x 32dp Optical Square: 24dp x 24dp Color (Enabled): #FFFFFF 80% opacity Color (Disabled): #FFFFFF 30% opacityClick here to download the project code
Use $mod to get the even numbers and pull them from the array. Let us first create a collection with documents −>db.pullEvenNumbersDemo.insertOne({"AllNumbers":[101, 102, 104, 106, 108, 109, 110, 112, 14, 17, 18, 21]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd45b072cba06f46efe9eea") }Following is the query to display all documents from the collection with the help of find() method −> db.pullEvenNumbersDemo.find().pretty();This will produce the following output −{ "AllNumbers" : [ 102, 104, 106, 108, 109, 110, 112, ... Read More
To display JTabbedPane on the right, you need to set the location to the right using the constant RIGHT −JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);The following is an example to display JTabbedPane on the right −Examplepackage my; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Technologies"); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT); JPanel panel1, panel2, panel3, panel4, panel5; panel1 = new JPanel(); panel2 = new JPanel(); panel3 = new JPanel(); panel4 = ... Read More
Let’s say the following is our JTextArea −JTextArea textArea = new JTextArea("This is demo text.");Now, get the font using the Font class getFont() method as shown below −Font font = textArea.getFont(); System.out.println("Font = "+font);The following is an example to get JTextArea font information in Java −Examplepackage my; import java.awt.Font; import java.awt.GridLayout; import javax.swing.*; public class SwingDemo { SwingDemo(){ JFrame frame = new JFrame(); JTextArea textArea = new JTextArea("This is demo text."); Font font = textArea.getFont(); System.out.println("Font = "+font); frame.add(textArea); frame.setSize(550, 300); ... Read More
Pass by value In pass by value, a function is called by directly passing the value of the variable as the argument. Changing the argument inside the function doesn’t affect the variable passed from outside the function. Javascript always pass by value so changing the value of the variable never changes the underlying primitive (String or number).In the following example, variable 'a' has assigned value 1. But inside function 'change' it got assigned with value 2. Since javascript is always a pass by value, the displayed output will be '1' but not '2'.ExampleLive Demo let a = 1; ... Read More
To connect with a database using JDBC you need to select get the driver for the respective database and register the driver. You can register a database driver in two ways −Using Class.forName() method − The forName() method of the class named Class accepts a class name as a String parameter and loads it into the memory, Soon the is loaded into the memory it gets registered automatically.Class.forName("com.mysql.jdbc.Driver");ExampleFollowing JDBC program establishes connection with MySQL database. Here, we are trying to register the MySQL driver using the forName() method.import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class RegisterDriverExample { public static ... Read More
For this, you can use LEAST(). Following is the syntax −select least(yourColumnName, yourMaxValue) from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(50); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(201); Query OK, 1 row affected (0.12 sec) ... Read More