Both pow() and power() are synonyms. Let us see the syntax −select pow(yourValue1, yourValue2); OR select power(yourValue1, yourValue2);Now we will see some examples.Using pow()mysql> select POW(4, 3);This will produce the following output −+----------+ | POW(4, 3) | +----------+ | 64 | +----------+ 1 row in set (0.00 sec)Using power()mysql> select POWER(4, 3);This will produce the following output −+------------+ | POWER(4, 3) | +------------+ | 64 | +------------+ 1 row in set (0.00 sec)Let us first create a table and look into the above concept ... Read More
The "this" keyword in Java is a reference to the object of the current class. Using it, you can refer a field, method or, constructor of a class.Referring to a field using "this" keywordAs discussed you can refer an instance filed/variable of a class from an instance method or, a constructor using "this" keyword. i.e. If a method has a local variable with the name same as instance variable then, you can differentiate the instance variable from the local variable using this It.ExampleIn the following Java example, the class Student has two private fields name and age, with setter and getter methods. The ... Read More
We can set or disallow selection of cell in the table using setCellSelectionEnabled(). The following is an example. −If you want to allow selection of cell, then set the method to TRUE −table.setCellSelectionEnabled(true);If you want to disallow selection of cell, then set the method to FALSE −table.setCellSelectionEnabled(false);Here we have disallowed selection of a cell −Examplepackage my; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; public class SwingDemo { public static void main(String[] argv) throws Exception { DefaultTableModel tableModel = new DefaultTableModel(); JTable table = new JTable(tableModel); tableModel.addColumn("Language/ Technology"); ... Read More
At first, we will create a slider and set it to snap to tick marks:JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 40); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setSnapToTicks(true);After that, we will check whether the slider is currently snapping to tick marks. The result would be displayed in the TRUE/FALSE booleanslider.getSnapToTicks()Display the result in the Console as shown below:System.out.println("Snapping to tick marks? = "+slider.getSnapToTicks());The following is an example to determine whether the slider is currently snapping to tick marks:Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) ... Read More
To get the minimum value, use sort() along with limit(1). Let us first create a collection with documents −> db.findMinimumValueDemo.insertOne({"Value":1004}); { "acknowledged" : true, "insertedId" : ObjectId("5cdfd61abf3115999ed51208") } > db.findMinimumValueDemo.insertOne({"Value":983}); { "acknowledged" : true, "insertedId" : ObjectId("5cdfd61ebf3115999ed51209") } > db.findMinimumValueDemo.insertOne({"Value":990}); { "acknowledged" : true, "insertedId" : ObjectId("5cdfd622bf3115999ed5120a") } > db.findMinimumValueDemo.insertOne({"Value":1093}); { "acknowledged" : true, "insertedId" : ObjectId("5cdfd626bf3115999ed5120b") } > db.findMinimumValueDemo.insertOne({"Value":10090}); { "acknowledged" : true, "insertedId" : ObjectId("5cdfd62fbf3115999ed5120c") }Following is the query to display all documents from a collection with the help of find() method −> db.findMinimumValueDemo.find();This will produce the following ... Read More
The HTML DOM Anchor hreflang property is used to set or return the value of the hreflang attribute of a link.Following is the syntax to set the hreflang property −anchorObj.hreflang = language_codeAbove, language_code represents the language of the linked document. This language code examples, include en for English, bn for Bengali, hi for Hindi, fr for French, la for Latin, ru for Russian, etc.Following is the syntax to return the hreflang property −anchorObj.hreflangLet us now see an example to implement the DOM Anchor hreflang property −Example Live Demo Company Products Display href Part Display Host Part Display hreflang ... Read More
SQL databases provide a datatype named Blob (Binary Large Object) in this, you can store large binary data like images.To retrieve binary (stream) values from a table JDBC provides a method called getBinaryStream() in the PreparedStatement interface.It accepts an integer representing the index of the column of the table and retrieves the binary data from it.You can retrieve binary data from a table using this method as shown below −FileInputStream fin = new FileInputStream("javafx_logo.jpg"); pstmt.setBinaryStream(3, fin);ExampleLet us create a table with name tutorials_data in MySQL using the CREATE statement as shown below −CREATE TABLE tutorials_data( Name VARCHAR(255), Type ... Read More
Here we will see one program that will help to check whether a matrix is bisymmetric or not. The Bisymmetric matrix is one square matrix that are symmetric about both of the major diagonals. The below matrix is an example of bisymmetric matrix.1 2 3 4 5 2 6 7 8 4 3 7 9 7 3 4 8 7 6 2 5 4 3 2 1AlgorithmcheckBiSymmetric(mat, n)Begin for i in range 0 to n – 1, do for j in range 0 to i – 1, do if mat[i, j] is ... Read More
Here, we are sorting string array alphabetically by the initial character i.e. ‘J’ for ‘John’ will come after ‘Chris’ since the first character of ‘Chris’ is ‘C’.Let us first create a String array:String[] strArr = { "PQRS", "AB", "RSTUVW", "RST", "U", "UVWXY", "OUJBG" };Now, sort the string array based on the first character:Arrays.sort(strArr, (str1, str2) -> str1.charAt(0) - str2.charAt(0));The following is an example to sort String Array alphabetically by the initial character only:Exampleimport java.util.Arrays; public class Demo { public static void main(String[] args) { String[] strArr = { "PQRS", "AB", "RSTUVW", "RST", "U", "UVWXY", "OUJBG" }; ... Read More
JLabel Left AlignedThe following is an example to set left alignment for JLabel −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Demo"); JLabel label; label = new JLabel("Left aligned!", JLabel.LEFT); label.setFont(new Font("Verdana", Font.PLAIN, 13)); frame.add(label); frame.setSize(500, 300); frame.setVisible(true); } }OutputJLabel Center AlignedThe following is an example to set center alignment for JLabel −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) ... Read More