Explain JavaScript Bitwise NOT, Left shift and Right shift?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

124 Views

JavaScript Bitwise NOT Live DemoExample document.getElementById("not").innerHTML = ~ 13; Output-14Explanation: It gives 0 for 1 and 1 for 0.The above result is 14.JavaScript Bitwise leftshift operator Live DemoExample document.getElementById("left").innerHTML = 5

How to apply adjustments to the next column of a JTable only, when the width of a column is changed in Java Swing?

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

109 Views

To apply adjustments to the next column only, use the setAutoResizeMode and set the mode. The mode here would be AUTO_RESIZE_NEXT_COLUMN. This will allow you to adjust only the next column even if any of the column header is dragged to resize.Let us first see an example to create a table −Examplepackage my; import java.awt.Font; 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("Technology");       tableModel.addColumn("BCA"); ... Read More

How to calculate timestamp difference in hours with MongoDB?

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

757 Views

To calculate timestamp difference, use aggregate framework. Let us first create a collection with documents −> db.timestampDifferenceDemo.insertOne({    "MovieBeginningTime": new ISODate("2019-05-12 10:20:30"),    "MovieEndingTime":new ISODate("2019-05-12 12:30:20") }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ba1f6d78f205348bc644") } > db.timestampDifferenceDemo.insertOne({    "MovieBeginningTime": new ISODate("2019-05-12 04:00:00"),    "MovieEndingTime":new ISODate("2019-05-12 07:10:00") }); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd7ba3b6d78f205348bc645") }Following is the query to display all documents from a collection with the help of find() method −> db.timestampDifferenceDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cd7ba1f6d78f205348bc644"),    "MovieBeginningTime" : ISODate("2019-05-12T10:20:30Z"),    "MovieEndingTime" : ISODate("2019-05-12T12:30:20Z") } {    "_id" : ... Read More

Elaborate the legal operands of the instance of operator in java?

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

84 Views

The instanceof operator in Java is used to find whether a reference is an instance of a Type i.e. class or an interface.Example Live Demopublic class InstanceOfExample {    public static void main(String args[]) {       String str = "hello";       boolean bool = str instanceof String;       System.out.println(bool);    } }OutputtrueLegal operands of the instanceof operatorThe following are the only legal operands of the instanceof operator −Left operand − It must be a reference representing an object.Right operand − It must be the name of Java class or, interface.Except these two if you use ... Read More

c16rtomb() function in C/C++?

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

98 Views

In C++, we can use 16-bit character representations. The c16rtomb() function is used to convert 16-bit character representation to narrow multi-byte character representation. We can find this function inside the uchar.h header file.This function takes three parameters. These are −The string where multi-byte character will be stored16-bit character to convertThe pointer of type mbstate_t object. which is used to interpret multibyte string.This function returns number of bytes written to the character array, when it is successful, otherwise returns -1. Let us see an example to get better idea.Example Live Demo#include #include #include using namespace std; int main() { ... Read More

What is NaN in C++?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

713 Views

The NaN is the abbreviation of Not a Number. It indicates undefined or non-representable floating point elements. One example of NaN is square root of some negative number, or result of 0/0.Example#include #include using namespace std; int main() {    cout >> "Square root of -5: " >> sqrt(-5) >> endl; }OutputSquare root of -5: nan

Reverse a string in C/C++ using Client Server model

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

1K+ Views

Here we will see how we can create a system, where we will create one client, and a server, and the client can send one string to the server, and the server will reverse the string, and return back to the client.Here we will use the concept of socket programming. To make the client server connection, we have to create port. The port number is one arbitrary number that can be used by the socket. We have to use the same port for client and the server to establish the connection.To start the program, start the server program first −gcc ... Read More

How to schedule local notifications in Android?

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

2K+ Views

This example demonstrate about How to schedule local notification in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to res/menu/main_menu.xml.             Step 4 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.AlarmManager ; import android.app.Notification ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Context ; import android.content.Intent ; import android.os.Bundle ; import android.os.SystemClock ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ... Read More

How to delete a table from MongoDB database?

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

356 Views

Use drop() to delete a table. Following is the syntax −db.yourCollectionName.drop();Let us first create a collection with documents −> db.deleteTableDemo.insertOne({"Name":"Chris", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccfb705140b992277dae0e6") } > db.deleteTableDemo.insertOne({"Name":"Carol", "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccfb70c140b992277dae0e7") } > db.deleteTableDemo.insertOne({"Name":"David", "Age":24}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccfb714140b992277dae0e8") }Following is the query to display all documents from a collection with the help of find() method −> db.deleteTableDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5ccfb705140b992277dae0e6"),    "Name" : "Chris",    "Age" : 23 } {    "_id" : ObjectId("5ccfb70c140b992277dae0e7"),   ... Read More

Customize the JOptionPane layout with updated color and image in Java

George John
Updated on 30-Jul-2019 22:30:26

1K+ Views

Customize the layout by changing the look and feel of the panel in which you added the component −ImageIcon icon = new ImageIcon(new URL("http −//www.tutorialspoint.com/images/C-PLUS.png")); JLabel label = new JLabel(icon); JPanel panel = new JPanel(new GridBagLayout()); panel.add(label); panel.setOpaque(true); panel.setBackground(Color.ORANGE);Above, we have added an image and even updated the background color of the panel.Now, set it for the text panel −JPanel textPanel = new JPanel(new GridLayout(10, 5)); textPanel.setBackground(Color.Magenta);The following is an example to customize the JOptionPane layout −Examplepackage my; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.net.URL; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; public class SwingDemo { ... Read More

Advertisements