C++ Program That Will Fill Whole Memory

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

363 Views

In this article we will see how to fill the whole memory by writing a simple C++ program. Here the logic is very simple. We shall create new integer variables by using the dynamic memory allocation. If we create some variables again and again, it will fill the entire primary memory.In C++ to dynamically allocate a memory space we can use the new keyword.The basic syntax of the new operator is like below.pointer_var = new data_typeTo deallocate the memory space, we can use the delete keyword. The syntax isdelete pointer_varNote After running this program it may slow down the performance ... Read More

Add New Field to Every Document in a MongoDB Collection

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

2K+ Views

To add new field to every document in a MongoDB collection, you can use $set operator. The syntax is as follows:db.yourCollectionName.update({}, { $set: {"yourFieldName": yourValue} }, false, true);To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents is as follows:>db.addNewFieldToEveryDocument.insertOne({"StudentName":"John", "StudentAddress":"US "}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6efc0b6fd07954a48906ae") } >db.addNewFieldToEveryDocument.insertOne({"StudentName":"David", "StudentAddress":"U K"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6efc0b6fd07954a48906af") } >db.addNewFieldToEveryDocument.insertOne({"StudentName":"Carol", "StudentAddress":"U K"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6efc0b6fd07954a48906b0") } >db.addNewFieldToEveryDocument.insertOne({"StudentName":"Bob", "StudentAddress":"US" }); {    "acknowledged" : true,    "insertedId" : ... Read More

Enable Vertical Scroll Bar for Android WebView

Nitya Raut
Updated on 30-Jul-2019 22:30:25

3K+ Views

This example demonstrate about How to set default text encoded for android webview.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. In the above code, we have taken web view to show facebook.com.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ProgressDialog; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.webkit.CookieManager; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.EditText; public class MainActivity extends ... Read More

LocalTime isBefore Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

500 Views

It can be checked if a particular LocalTime is before the other LocalTime in a timeline using the isBefore() method in the LocalTime class in Java. This method requires a single parameter i.e. the LocalTime object that is to be compared. It returns true if the LocalTime object is before the other LocalTime object and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt1 = LocalTime.parse("11:37:12");       LocalTime lt2 = LocalTime.parse("23:15:30");       System.out.println("The LocalTime lt1 is: " ... Read More

Period minusYears Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

168 Views

An immutable copy of the Period object where some years are subtracted from it can be obtained using the minusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be subtracted and it returns the Period object with the subtracted years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P5Y7M15D";       Period p1 = Period.parse(period);       System.out.println("The Period is: " + p1);       Period p2 ... Read More

Packet over SONET

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

Synchronous optical networking (SONET) is a physical layer protocol for transmitting multiple digital bit streams over optical fiber links that form the backbone of the communication networks. Packet-over-SONET (POS) is a standard that maps IP packets into SONET frames. To implement this mechanism, Point – to – Point Protocol (PPP) runs on IP routers. Point – to – Point Protocol (PPP) is a data link layer protocol that is used to transmit data between two directly connected (point-to-point) computers. It is a byte-oriented protocol that is widely used in broadband communications having heavy loads and high speeds.The following diagram shows ... Read More

MySQL Update Using IF Condition

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

11K+ Views

The syntax is as follows to perform UPDATE using IF condition in MySQL −update yourTableName set yourColumnName =if(yourColumnName =yourOldValue, yourNewValue, yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table updateIfConditionDemo    -> (    -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserName varchar(20),    -> UserAge int    -> ); Query OK, 0 rows affected (4 min 0.59 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into updateIfConditionDemo(UserName, UserAge) values('Larry', 23); Query OK, ... Read More

Initialize a Vector in C++

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

1K+ Views

Initialization vector can be done in many ways1) Initialize a vector by push_back() methodAlgorithmBegin    Declare v of vector type.    Call push_back() function to insert values into vector v.    Print “Vector elements:”.    for (int a : v)       print all the elements of variable a. End.Example Live Demo#include #include using namespace std; int main() {    vector v;    v.push_back(6);    v.push_back(7);    v.push_back(10);    v.push_back(12);    cout

Terminate a MongoDB Shell Script Earlier

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

541 Views

In order to terminate a MongoDB shell script earlier, you need to use quit. Following is the syntaxquit() quit(1)Let us create a script and try to write quit() or quit(1) in shell. At first, we will create the following collection with documents> db.flightInformation.insertOne({"FlightName":"Flight-1", "ArrivalTime":new ISODate("2019-03-12")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e341e941bbb0e8bf5639") } > db.flightInformation.insertOne({"FlightName":"Flight-2", "ArrivalTime":new ISODate("2019-03-31")}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca1e351e941bbb0e8bf563a") }Following is the query to display all documents from a collection with the help of find() method> db.flightInformation.find().pretty();This will produce the following output{    "_id" : ObjectId("5ca1e341e941bbb0e8bf5639"),    "FlightName" : "Flight-1",   ... Read More

Create a Read-Only List in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

292 Views

Let us first create a List in Java −Listlist = new ArrayList(); list.add("A"); list.add("B"); list.add("C");Now to convert the above list to read-only, use Collections −list = Collections.unmodifiableList(list);We have converted the above list to read-only. Now, if you will try to add more elements to the list, then the following error would be visible −Exception in thread "main" java.lang.Error: Unresolved compilation problem:Example Live Demoimport java.util.ArrayList; import java.util.Collections; import java.util.List; public class Demo {    public static void main(String args[]) throws Exception {       Listlist = new ArrayList();       list.add("A");       list.add("B");       list.add("C");   ... Read More

Advertisements