Find Highest Numeric Value of a Column in MongoDB

Samual Sam
Updated on 02-Jul-2020 11:33:59

194 Views

You can use $not operator along with $type for this. Let us first create a collection with documents −> db.highestNumericValueOfAColumnDemo.insertOne( ...    { ...       "StudentName": "John", ...       "StudentMathMarks":69 ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cba05727219729fde21ddb1") } > db.highestNumericValueOfAColumnDemo.insertOne( ...    { ...       "StudentName": "Carol", ...       "StudentMathMarks":"89" ...    } ... ); {    "acknowledged" : true,    "insertedId" : ObjectId("5cba059d7219729fde21ddb2") } > db.highestNumericValueOfAColumnDemo.insertOne( ...    { ...       "StudentName": "Chris", ...       "StudentMathMarks":82 ...    } ... ... Read More

Comma Separated Argument for IN Operator in MySQL

AmitDiwan
Updated on 02-Jul-2020 11:32:42

243 Views

Use FIND_IN_SET() for command separated argument. Let us first create a table −mysql> create table DemoTable604 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Title varchar(100)); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable604(Title) values('MySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable604(Title) values('C++'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable604(Title) values('MongoDB'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable604(Title) values('Java'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable604;This ... Read More

Create Tooltips with CSS

Jennifer Nicholas
Updated on 02-Jul-2020 10:58:25

144 Views

A tooltip is visible when a user moves the mouse cursor on a text. You can add information in it to make it easy for users to understand.ExampleYou can try to run the following code to learn how to create tooltip −Live Demo           #mytooltip #mytext {          visibility: hidden;          width: 100px;          background-color: black;          color: #fff;          text-align: center;          border-radius: 3px;          padding: 10px 0;          position: absolute;          z-index: 1;       }       #mytooltip:hover #mytext {          visibility: visible;       }               Hover the mouse over me          My Tooltip text          

Difference Between Byte Stream and Character Stream Classes in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:37:19

5K+ Views

Java provides I/O Streams to read and write data where, a Stream represents an input source or an output destination which could be a file, i/o devise, other program etc.Based on the data they handle there are two types of streams −Byte Streams − These handle data in bytes (8 bits) i.e., the byte stream classes read/write data of 8 bits. Using these you can store characters, videos, audios, images etc.Character Streams − These handle data in 16 bit Unicode. Using these you can read and write text data only.The Reader and Writer classes (abstract) are the super classes of ... Read More

Print Message Without Using println Method in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:34:27

7K+ Views

The println() method of the System class accepts aStringas parameter an prints the given String on the console.Examplepublic class PrintData {    public static void main(String args[]) {       System.out.println("Hello how are you");    } }OutputHello how are youIn addition to this you can print data on the console in several other ways, some of them are −Using Output StreamsUsing output stream classes, you can write dat on the specified destination. You can print data on the screen/console by passing the standard output Stream object System.out as source to them.Exampleimport java.io.IOException; import java.io.OutputStreamWriter; public class PrintData {   ... Read More

Synchronize the String Type in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:33:35

2K+ Views

A thread is a piece of code (under execution) in a program, which executes a sub task of the process independently. independent process.In other words, a thread is a light weight process which executes a piece of code independently.Thread synchronizationIf a process has multiple threads running independently at the same time (multi-threading) and if all of them trying to access a same resource an issue occurs.To resolve this, Java provides synchronized blocks/ synchronized methods. If you define a resource (variable/object/array) inside a synchronized block or a synchronized method, if one thread is using/accessing it, other threads are not allowed to ... Read More

Why String Class is Popular Key in a HashMap in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:32:54

3K+ Views

A map is a collection in Java which stores key value pairs. The keys of this must not be null and each key should point to only one value. It is represented by the Map interface of java.util package. There are various classes which provides implementation to this interface.The HashMap is a class which implements the Map interface. It is based on the Hash table. It allows null values and null keys.In short, you can store key value pairs in the HashMap object. Once you do so you can retrieve the values of the respective keys but, the values we ... Read More

Convert String to StringBuilder and Vice Versa in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:32:03

22K+ Views

The String type is a class in Java, it is used to represent a set of characters. Strings in Java are immutable, you cannot change the value of a String once created.Since a String is immutable, if you try to reassign the value of a String. The reference of it will be pointed to the new String object leaving an unused String in the memory.Java provides StringBuffer class as a replacement of Strings in places where there is a necessity to make a lot of modifications to Strings of characters.You can modify/manipulate the contents of a StringBuffer over and over again ... Read More

Guidelines for Implementing equals() Method in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:25:05

218 Views

To compare two objects, the Object class provides a method with name equals(), this method accepts an object and compares it with the current object.If the references of these two objects are equal, then it returns true else this method returns false.But this method returns true only if both references points to the same object. In fact, it should return true id the contents of the both objects are equal.Exampleclass Employee {    private String name;    private int age;    Employee(String name, int age){       this.name = name;       this.age = age;    } } ... Read More

Default Method vs Static Method in an Interface in Java

Maruthi Krishna
Updated on 02-Jul-2020 10:22:11

9K+ Views

An interface in Java is similar to class but, it contains only abstract methods and fields which are final and static.Since Java8 static methods and default methods are introduced in interfaces.Default Methods - Unlike other abstract methods these are the methods can have a default implementation. If you have default method in an interface, it is not mandatory to override (provide body) it in the classes that are already implementing this interface.In short, you can access the default methods of an interface using the objects of the implementing classes.Exampleinterface MyInterface{    public static int num = 100;    public default void ... Read More

Advertisements