Let us first create an int array −int[] arr = new int[10];Now, fill array values. Here, the numbers get added from the index 2 to 7 −Arrays.fill(arr, 2, 7, 100);Example Live Demoimport java.util.Arrays; public class Demo { public static void main(String[] args) { int[] arr = new int[10]; System.out.println("Array = "+Arrays.toString(arr)); Arrays.fill(arr, 2, 7, 100); System.out.println("Fill = "+Arrays.toString(arr)); } }OutputArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Fill = [0, 0, 100, 100, 100, 100, 100, 0, 0, 0]
In this program a random graph is generated for random vertices and edges. The time complexity of this program is O(v * e). Where v is the number of vertices and e is the number of edges.AlgorithmBegin Develop a function GenRandomGraphs(), with ‘e’ as the number of edges and ‘v’ as the number of vertexes, in the argument list. Assign random values to the number of vertex and edges of the graph, using rand() function. Print the connections of each vertex, irrespective of the direction. ... Read More
Canada is one of the most popular countries which is most sought after for immigrants and students alike. The process to obtain a work visa is relatively stress-free.Apart from your academic scores, subjects, and your interview procedure, to get a job in Canada, you need to write only one exam to prove your English Language Proficiency. It is the IELTS (International English Language Testing System). You need to score at least 7 or more bands for getting good chances to migrate to Canada. That's it.
The three clock cycles at the last stages in the IN 35H instruction is an example of machine cycle for IOR. The Waveforms for the IOR machine cycle are shown in the figure below.The point to be noted that in an IOR machine cycle, Wand Z has identical has port address of 8 bit. The value of 16 bit in the register pair WZ are sent out as the address in an Input Output Read machine cycle. Also the point to be noted that in an IOR machine cycle, only the data is received by the accumulator from the addressed ... Read More
Before getting into example, we should know what sqlite database in android is. SQLite is an opensource SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use NOT NULL constraints in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More
To get the record before the last one i.e. the second last record in MySQL, you need to use subquery.The syntax is as followsSELECT *FROM (SELECT *FROM yourTableName ORDER BY yourIdColumnName DESC LIMIT 2) anyAliasName ORDER BY yourIdColumnName LIMIT 1;Let us first create a table. The query to create a table is as followsmysql> create table lastRecordBeforeLastOne - > ( - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > Name varchar(20) DEFAULT 'John', - > Age int DEFAULT 18 - > ); Query OK, 0 rows affected (0.79 sec)Now you can insert some ... Read More
We have two types of ResultSet objects namely, forward Only and, bi-directional as the names suggest you can move in only one direction (forward) in forward only ResultSet and, in bidirectional ResultSet you can move the pointer in both directions. The ResultSet interface provides several methods to navigate through both types of ResultSet objects.Following table lists various methods to navigate through ResultSet object.MethodDescriptionnext()This method moves the resultset pointer one row forward.Previous() This method moves the resultset pointer one row backward.first()This method moves the resultset pointer to the first row.last()This method moves the resultset pointer to the last row.relative()This method accepts an ... Read More
An immutable copy of a LocalDateTime object where some months are added to it can be obtained using the plusMonths() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the LocalDateTime object with the added months.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDateTime ldt = LocalDateTime.now(); System.out.println("The current LocalDateTime is: " + ldt); System.out.println("The LocalDateTime with 5 months added is: ... Read More
The iterator() method of the IntStream class in Java is used to return an iterator for the elements of this stream.The syntax is as followsPrimitiveIterator.OfInt iterator()Here, PrimitiveIterator.OfInt is an Iterator specialized for int values. To work with the IntStream class in Java, import the following packageimport java.util.stream.IntStream;Create an IntStream and add some elementsIntStream intStream = IntStream.of(15, 40, 55, 70, 95, 120);To return an iterator for the stream elementsPrimitiveIterator.OfInt primIterator = intStream.iterator();The following is an example to implement IntStream iterator() method in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { ... Read More
To aggregate sum in MongoDB to get the total count, you can use the $sum operator. To understand the above concept, let us create a collection with the document −> db.aggregateSumDemo.insertOne({"CustomerName":"Larry", "Amount":140}); { "acknowledged" : true, "insertedId" : ObjectId("5c8baa0680f10143d8431e18") } > db.aggregateSumDemo.insertOne({"CustomerName":"Mike", "Amount":160}); { "acknowledged" : true, "insertedId" : ObjectId("5c8baa1380f10143d8431e19") } > db.aggregateSumDemo.insertOne({"CustomerName":"Sam", "Amount":300}); { "acknowledged" : true, "insertedId" : ObjectId("5c8baa1c80f10143d8431e1a") } > db.aggregateSumDemo.insertOne({"CustomerName":"David", "Amount":500}); { "acknowledged" : true, "insertedId" : ObjectId("5c8baa2580f10143d8431e1b") }Display all documents from a collection with the help of find() method. The query is as follows −> db.aggregateSumDemo.find().pretty();The following ... Read More