It is basically pointless to check for a NULL pointer before deleting. Deleting a pointer will do nothing if the pointer set to NULL. It might be the reason to check for the NULL pointer that deleting a pointer which is already set to NULL may indicate bugs in the program.
A complex number is created from real numbers. Python complex number can be created either using direct assignment statement or by using complex () function.Complex numbers which are mostly used where we are using two real numbers. For instance, an electric circuit which is defined by voltage(V) and current(C) are used in geometry, scientific calculations and calculus.Syntaxcomplex([real[, imag]])Creating a simple complex number in python>>> c = 3 +6j >>> print(type(c)) >>> print(c) (3+6j) >>> >>> c1 = complex(3, 6) >>> print(type(c1)) >>> print(c1) (3+6j)From above results, we can see python complex numbers are of type complex. Each complex ... Read More
In this section we will see the nullptr in C++. The nullptr denotes the pointer literals. It is a prvalue of type std::nullptr_t. It has implicit conversion property from nullptr to null pointer value of any pointer type and any pointer to member type. Let us see one program, to understand this concept.Example#include using namespace std; int my_func(int N){ //function with integer type parameter cout
The commit() method of the Connection interface saves all the modifications made since the last commit.con.save()If any issue occurs after the commit you can revert all the changes done till this commit by invoking the rollback() method.Con.rollback()To commit a transactionRegister the driver using the registerDriver() method of the DriverManager class as −//Registering the Driver DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get the connection using the getConnection() method of the DriverManager class as −//Getting the connection String url = "jdbc:mysql://localhost/mydatabase"; Connection con = DriverManager.getConnection(url, "root", "password");Turn off the auto-commit using the setAutoCommit() method as −//Setting the auto commit false con.setAutoCommit(false);Commit the transaction using the commit() method as −con.commit();Let us create a table with ... Read More
You can use dot(.) notation along with array index to get record beginning with specific element. Let us first create a collection with documents −>db.arrayStartsWithElementDemo.insertOne({"PlayerName":"Chris", "PlayerScore":[780, 9000, 456, 789, 987]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd29fed345990cee87fd889") } >db.arrayStartsWithElementDemo.insertOne({"PlayerName":"Robert", "PlayerScore":[890, 670, 890, 54646, 42424]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2a00c345990cee87fd88a") } >db.arrayStartsWithElementDemo.insertOne({"PlayerName":"David", "PlayerScore":[909090, 896555, 3344433, 78900]}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2a025345990cee87fd88b") }Following is the query to display all documents from a collection with the help of find() method −> db.arrayStartsWithElementDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cd29fed345990cee87fd889"), ... Read More
Minor Tick marks is the number passed in representing the distance between each minor tick mark. For example, a slider with range from 0 to 70 and minor tick spacing 10, would give minor ticks next to the following values: 0, 10, 20, 30, 40, 50, 60, 70.To set minor tick marks, use the setMinorTickSpacing() method −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 60); slider.setMinorTickSpacing(10);Note − For minor ticks to be painted, you need to set setPaintTicks to true.The following is an example to set minor tick marks in a slider every 10 units −Examplepackage my; import javax.swing.JFrame; import javax.swing.JPanel; ... Read More
To get the path of the selected file, at first get the selected file −java.io.File f = file.getSelectedFile();Now, get the path of the selected file which we will get using the above method −System.err.println(f.getPath());The following is an example to get the path of the file selected in the JFileChooser component −Examplepackage my; import javax.swing.JFileChooser; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(true); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); file.setFileHidingEnabled(false); if (file.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { java.io.File f = ... Read More
Let us first see the syntax to drop a collection −db.getCollection("yourCollectionNameWithTwoDashes").drop();For demo, we will create a collection name with two dashes as shown below −> db.createCollection("company--EmployeeInformation"); { "ok" : 1 }Create the above collection “company--EmployeeInformation “ with documents. Following is the query:>db.getCollection("company--EmployeeInformation").insertOne({"CompanyName":"Amazon", "EmployeeName":"Chris"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7c5ff6d78f205348bc654") } >db.getCollection("company--EmployeeInformation").insertOne({"CompanyName":"Google", "EmployeeName":"Robert"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7c60b6d78f205348bc655") }Following is the query to display all documents from a collection with the help of find() method −> db.getCollection("company--EmployeeInformation").find();This will produce the following output −{ "_id" : ObjectId("5cd7c5ff6d78f205348bc654"), "CompanyName" : "Amazon", "EmployeeName" : "Chris" } { ... Read More
If we need to modify a pointer rather than the object that the pointer is pointing to, we pass a pointer by reference.Here is an example of how to pass a pointer by reference −Example Live Demo#include using namespace std; void Decrement( int*& d ) { --d; } int main( void ) { int a = 26; int* ptr = &a; // pointer to pass // print before decrement cout
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Type Casting/type conversion − Converting one primitive datatype into another is known as type casting (type conversion) in Java. You can cast the primitive datatypes in two ways namely, Widening and, Narrowing.Widening − Converting a lower datatype to a higher datatype is known as widening. In this case the casting/conversion is done automatically therefore, it is known as implicit type casting. In this case both datatypes should be compatible ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP