Smita Kapse has Published 558 Articles

Java Program to place component in bottom-right corner with BorderLayout

Smita Kapse

Smita Kapse

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

921 Views

We have created a button component here, which will places in bottom-right corner −JButton button = new JButton("This is Demo Text!"); button.setBackground(Color.blue); button.setForeground(Color.white);Create panels now to arrange the above created button component in the bottom right −JPanel bottomPanel = new JPanel(new BorderLayout()); bottomPanel.add(button, BorderLayout.LINE_END); JPanel mainPanel = new JPanel(new BorderLayout()); ... Read More

How can I get a file's size in C++?

Smita Kapse

Smita Kapse

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

13K+ Views

To get a file’s size in C++ first open the file and seek it to the end. tell() will tell us the current position of the stream, which will be the number of bytes in the file.Example Live Demo#include #include using namespace std; int main() {    ifstream in_file("a.txt", ios::binary);   ... Read More

Reverse array field in MongoDB?

Smita Kapse

Smita Kapse

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

197 Views

To reverse array field in MongoDB, you can use forEach(). Let us first create a collection with documents −> db.reverseArrayDemo.insertOne({"Skills":["C", "Java"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ccddf99dceb9a92e6aa1946") }Following is the query to display all documents from a collection with the help of find() method −> db.reverseArrayDemo.find().pretty();This will ... Read More

How to find the size of an int[] in C/C++?

Smita Kapse

Smita Kapse

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

7K+ Views

In this section, we will see how we can get the size of an integer array in C or C++? The size of int[] is basically counting the number of elements inside that array. To get this we can use the sizeof() operator. If the array name is passed inside ... Read More

How to set the alignment of the JLabel content along the X axis on the left in Java

Smita Kapse

Smita Kapse

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

98 Views

To set the alignment of the label content along the X axis on the left, use the setHorizontalAlignment() method and set the location. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content ... Read More

How to find documents with exactly the same array entries as in a MongoDB query?

Smita Kapse

Smita Kapse

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

75 Views

For this, use the $all operator. Let us first create a collection with documents −>db.findDocumentExactlySameInArrayDemo.insertOne({"TechnicalSubjects":["C++", "Java", "MongoDB"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69a5f57806ebf1256f12e") } >db.findDocumentExactlySameInArrayDemo.insertOne({"TechnicalSubjects":["MySQL", "Java", "MongoDB"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cd69ac057806ebf1256f12f") } >db.findDocumentExactlySameInArrayDemo.insertOne({"TechnicalSubjects":["C#", "Python", "MongoDB"]}); {    "acknowledged" : true,    "insertedId" ... Read More

Read integers from a text file with C++ ifstream

Smita Kapse

Smita Kapse

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

6K+ Views

Here is an example of Read integers from a text file with C++ ifstream.Example#include #include using namespace std; int main() {    //initialie the array size    int arr[30];    ifstream is("a.txt");    int cnt= 0;    int x;    // check that array is not already full   ... Read More

How to use Reference Parameters in C++?

Smita Kapse

Smita Kapse

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

151 Views

Here we will see how to pass reference of some variable in C++. Sometimes we call it as “Call by Reference”.The call by reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access ... Read More

How to set the alignment of the JLabel content along the Y axis on the top in Java

Smita Kapse

Smita Kapse

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

126 Views

To set the alignment of the label’s content along the Y axis on the top, use the setVerticalAlignment() method and set the location. Let us first set a label component. We have set the label background color as well so that we can check the alignment of the label’s content ... Read More

Applications of Pointers in C/C++

Smita Kapse

Smita Kapse

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

1K+ Views

To access array elementsWe can access array elements by using pointers.In CExample Live Demo#include int main() {    int a[] = { 60, 70, 20, 40 };    printf("%d", *(a + 1));    return 0; }Output70In C++Example Live Demo#include using namespace std; int main() {    int a[] = { 60, 70, 20, 40 };    cout

Advertisements