In the cmath library of C++, there are different functions for getting the square root except from sqrt. The sqrt is used basically for double type input. The others are used for float, long type data etc. Let us see the usage of these functions.The sqrt() FunctionThis function is used for double type data. So this returns square root of type double. The syntax is like below.double sqrt(double argument)Example#include #include #include using namespace std; main() { double x = 144.0; double y = 180.0; cout
You can get the list of tables in the current database in MySQL using the SHOW TABLES query.Show tables;Following JDBC program retrieves the list of tables in the database by executing the show tables query.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class ListingTables { public static void main(String args[]) throws Exception { //Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Getting the connection String mysqlUrl = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(mysqlUrl, "root", "password"); System.out.println("Connection established......"); //Creating a Statement object ... Read More
Both the methods are used to add elements to the array.But the only difference is unshift() method adds the element at the start of the array whereas push() adds the element at the end of the array.1) push()Array.push() method is used to add an element at the end of an array like a queue .In the following example it is shown how to add an element using push() method Live DemoExample var cars = ["Benz", "Lamborghini", "Tata safari"]; cars.push("Ferrari"); document.write(cars); OutputBenz, Lamborghini, Tata safari, Ferrari2) unshift()Array.unshift() method is ... Read More
Use FlowLayout.CENTER to lay out components in a flow to be centered with FlowLayout. The following is an example to lay out components in a flow to be centered with FlowLayout −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("WorldCup2019"); frame.setLayout(new FlowLayout(FlowLayout.CENTER)); JLabel label = new JLabel("WorldCup Hosting Country "); label.setPreferredSize(new Dimension(220, 70)); label.setOpaque(true); label.setBackground(Color.ORANGE); ... Read More
You can use $where operator for this. Let us first create a collection with documents −> db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":10, "Price2":50, "Price3":40}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd84b8bf3115999ed511e6") } > db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":11, "Price2":1, "Price3":120}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd84c6bf3115999ed511e7") } > db.sumOfFieldIsGreaterThanDemo.insertOne({"Price1":10, "Price2":9, "Price3":6}); { "acknowledged" : true, "insertedId" : ObjectId("5cdd84d2bf3115999ed511e8") }Following is the query to display all documents from a collection with the help of find() method −> db.sumOfFieldIsGreaterThanDemo.find();This will produce the following output −{ "_id" : ObjectId("5cdd84b8bf3115999ed511e6"), "Price1" : 10, "Price2" : 50, "Price3" : 40 } { "_id" : ObjectId("5cdd84c6bf3115999ed511e7"), "Price1" : ... Read More
The HTML DOM Anchor port property is used to set or return the port of the href attribute.Following is the syntax to set the port property−anchorObj.port = numAbove, num is the port number of the url.Following is the syntax to return the port property−anchorObj.portLet us now see an example to implement the DOM Anchor port property−Example Live Demo Demo heading Services Display pathname Display hreflang Display port function display1() { var a = document.getElementById("mylink").pathname; document.getElementById("myid").innerHTML = a; } function display2() { ... Read More
Unlike C/C++ Long in Python 3 have unlimited precision and there is no explicitly defined limit. The amount of available address space considered to be the practical limit.In python 2, integers will automatically switch to longs when they grown beyond their limit −Python 2>>> import sys >>> type(sys.maxint) >>> type(sys.maxint + 1) Python 3Maxint was removed in python 3, but sys.maxsize can often be used instead.>>> import sys >>> type (sys.maxsize) >>> type (sys.maxsize + 1) From above output we can see, in python 3 int and long are actually merged and the value has no such importance.#Python ... Read More
ResultSet holdability determines whether the ResultSet objects (cursors) should be closed or held open when a transaction (that contains the said cursor/ ResultSet object) is committed using the commit() method of the Connection interface.ResultSet interface provides two values to specify the holdability namely CLOSE_CURSORS_AT_COMMIT and HOLD_CURSORS_OVER_COMMITIf the holdability of the ResultSet object is set to this value. Whenever you commit/save a transaction using the commit() method of the Connection interface, the ResultSet objects created in the current transaction (that are already opened) will be closed.Therefore, if you need to close the ResultSet cursor after the commit automatically, set the ResultSet ... Read More
To create a collection correctly you need to use a MongoDB object in call i.e.db.createCollection("yourCollectionName");Let us implement the above syntax in order to create a collection and call it using a MongoDB object −> use sample; switched to db sample > db.createCollection("employeeInformation"); { "ok" : 1 }Display all the collections from the above ‘sample’ database −> db.getCollectionNames();This will produce the following output −[ "arraySizeErrorDemo", "atleastOneMatchDemo", "basicInformationDemo", "combinedAndOrDemo", "convertSQLQueryDemo", "copyThisCollectionToSampleDatabaseDemo", "countOrSizeDemo", "distinctOnMultipleFieldsDemo", "documentWithAParticularFieldValueDemo", "employee", "employeeInformation", "findListOfIdsDemo", "findMimimumElementInArrayDemo", "findSubstring", "getAllRecordsFromSourceCollectionDemo", "getElementWithMaxIdDemo", "insertDocumentWithDateDemo", "internalArraySizeDemo", ... Read More
To highlight a row in a table, you can use the addRowSelectionInterval() method. At first create a table −DefaultTableModel tableModel = new DefaultTableModel(); JTable table = new JTable(tableModel);Add some columns −tableModel.addColumn("Language/ Technology"); tableModel.addColumn("Text Tutorial"); tableModel.addColumn("Video Tutorial"); tableModel.addColumn("Views");Now, add rows to the table −tableModel.addRow(new Object[] { "NodeJS", "No", "Yes", "2350"}); tableModel.addRow(new Object[] { "MVC", "Yes", "No", "1500"}); tableModel.addRow(new Object[] { "ASP.NET", "Yes", "Yes", "3400"}); tableModel.addRow(new Object[] { "F#", "Yes", "No", "7890"}); tableModel.addRow(new Object[] { "Blockchain", "Yes", "No", "10600"}); tableModel.addRow(new Object[] { "SharePoint", "Yes", "Yes", "4900"});Highlight a single row by adding interval of rows. Set the same index for both the parameters ... Read More