The range of values for a ChronoField can be obtained using the range() method in the LocalDate class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values is required and it returns the range of values.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The LocalDate is: " + ld); ... Read More
The joining() method of the Collectors class in Java 8 returns a Collector that concatenates the input elements into a String, in encounter order.The syntax is as follows −public static Collector joining()Here, CharSequence is a readable sequence of char values, whereas String class represents character strings.To work with Collectors class in Java, import the following package −import java.util.stream.Collectors;The following is an example to implement Collectors.joining() method in Java 8 −Example Live Demoimport java.util.stream.Collectors; import java.util.stream.Stream; import java.util.Arrays; import java.util.List; public class Demo { public static void main(String[] args) { List list ... Read More
You can select unique value with the help of DISTINCT keyword.The syntax is as followsselect distinct yourColumnName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table selectUniqueValue -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20), -> Age int -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into selectUniqueValue(Name, Age) values('John', 21); ... Read More
In this section we will see what is the purpose of memset() function in C++. This function converts the value of a character to unsigned character and copies it into each of first n character of the object pointed by the given str[]. If the n is larger than string size, it will be undefined.The syntax of the memset() functionvoid* memset( void* str, int c, size_t n);In this example will use one string, then convert each character to some other character up to length n.Example Live Demo#include using namespace std; int main() { char str[] = "Hello World"; memset(str, ... Read More
Here is a C++ Program to Perform Greedy ColoringAlgorithm:Begin Take the number of vertices and edges as input. Create function greedyColoring() to assign color to vertices: A) Assign the first color to first vertex. B) Initialize the remaining vertices. C) Declare a temporary array to store the available colors. D) Assign color to the remaining vertices. Print the solution. EndExample Code#include #include using namespace std; int n,e,i,j; vector g; vector col; bool visit[1001]; void greedyColoring() { col[0] = 0; for (i=1;i
To remove _id from MongoDB result, you need to set 0 for _id field. Following is the syntaxdb.yourCollectionName.find({}, {_id:0});To understand it, let us create a collection with documents. Following is the query> db.removeIdDemo.insertOne({"UserName":"John", "UserAge":23}); { "acknowledged" : true, "insertedId" : ObjectId("5c9bb4042d66697741252440") } > db.removeIdDemo.insertOne({"UserName":"Mike", "UserAge":27}); { "acknowledged" : true, "insertedId" : ObjectId("5c9bb40c2d66697741252441") } > db.removeIdDemo.insertOne({"UserName":"Sam", "UserAge":34}); { "acknowledged" : true, "insertedId" : ObjectId("5c9bb4162d66697741252442") } > db.removeIdDemo.insertOne({"UserName":"Carol", "UserAge":29}); { "acknowledged" : true, "insertedId" : ObjectId("5c9bb4222d66697741252443") }Following is the query to display all documents from a collection with the help of find() method> db.removeIdDemo.find().pretty();This ... Read More
To generate two separate outputs, at first create a new Random object −private static final Random r = new Random();Now, let us declare a value −int val = 5;Loop from the value till 100 and generate random numbers between 1 to 100 −while (val
Here we will see how to define a macro called PRINT(x), and this will print whatever the value of x, passed as an argument.To solve this problem, we will use the stringize operator. Using this operator the x is converted into string, then by calling the printf() function internally, the value of x will be printed. Let us see the example to get the better idea.Example#include #define PRINT(x) printf(#x) int main () { PRINT(Hello); printf(""); PRINT(26); printf(""); PRINT(2.354721); printf(""); }OutputHello 26 2.354721
Singleton design pattern is a software design principle that is used to restrict the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. For example, if you are using a logger, that writes logs to a file, you can use a singleton class to create such a logger. You can create a singleton class using the following code.Example#include using namespace std; class Singleton { static Singleton *instance; int data; // Private constructor so that no objects can be created. Singleton() { ... Read More
We use Timing and Controlling unit in 8085 for the generation of timing signals and the signals to control. All the operations and functions both interior and exterior of a microprocessor are controlled by this unit. X2 and CLK output pins: To do or rather perform the operations of timing in the microcomputer system, we have a generator called clock generator in the CU of 8085. Other than the quartz crystal the complete circuit of the oscillator is within the chip. The two pins namely X1 and X2 are taken out from the chip to give the connection to the ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP