Difference Between Parcelable and Serializable in Android

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

482 Views

This example demonstrate about Difference between Parcel able and Serializable in androidSerializableSerializable is a markable interface or we can call as empty interface. It doesn’t have any pre-implemented methods. Serializable is going to convert object to byte stream. So user can pass the data between one activity to another activity. The main advantage of serializable is creation and passing data is very easy but it is a slow process compare to parcelable.A simple example of serializable as shown below –import java.io.Serializable; class serializableObject implements Serializable {    String name;    public serializableObject(String name) {       this.name = name; ... Read More

Check If Graph Is Bipartite Using 2-Color Algorithm in C++

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

309 Views

A bipartite graph is a graph in which if the graph coloring is possible using two colors i.e.; vertices in a set are colored with the same color. This is a C++ program to Check whether a graph bipartite or not using 2 color algorithm.Functions and pseudocodesBegin    1. Develop function isSafe() to check if the current color assignment       is safe for vertex v, i.e. checks whether the edge exists or not.       If it exists, then next check whether the color to be filled in       the new vertex is already used ... Read More

MongoDB Query to Get Specific Month and Year

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

718 Views

You can use aggregate framework along with $month projection operator. Let us first create a collection with documents −> db.specificMonthDemo.insertOne({"StudentName":"Larry", "StudentDateOfBirth":new ISODate('1995-01-12')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9a9ca8f1d1b97daf71819") } > db.specificMonthDemo.insertOne({"StudentName":"Chris", "StudentDateOfBirth":new ISODate('1999-12-31')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9a9db8f1d1b97daf7181a") } > db.specificMonthDemo.insertOne({"StudentName":"David", "StudentDateOfBirth":new ISODate('2000-06-01')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9a9ee8f1d1b97daf7181b") }Following is the query to display all documents from the collection with the help of find() method −> db.specificMonthDemo.find().pretty();This will produce the following output −{    "_id" : ObjectId("5cb9a9ca8f1d1b97daf71819"),    "StudentName" : "Larry",    "StudentDateOfBirth" : ISODate("1995-01-12T00:00:00Z") } {    "_id" ... Read More

What is Google Drive File Stream?

Anagha N
Updated on 30-Jul-2019 22:30:25

262 Views

Google Drive Filestream is launched by Google to allow you to quickly access all your files on google drive directly from the computer. It does not use your hard drive space !!It is a new desktop application created for the G-suite users which takes far less time to access the files, than the Google drive.The path to access the files is Apps > G Suite > Drive and Docs > Data Access.

Duration equals Method in Java

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

417 Views

The equality of two durations can be determined using the equals() method in the Duration class in Java. This method requires a single parameter i.e. the duration to be compared. Also, it returns true if both the durations are equal and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class GFG { public static void main(String[] args) { Duration d1 = Duration.ofDays(1); Duration d2 = Duration.ofHours(24); boolean flag = d1.equals(d2); ... Read More

Search a Value in Java Tuples Septet Class

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

96 Views

The contain() method is used to search a value in Septet class.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Septet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Septet; public class Demo {    public static void main(String[] args) {       Septet ... Read More

Exclude Entries with 0 in MySQL AVG Function

Chandu yadav
Updated on 30-Jul-2019 22:30:25

5K+ Views

To exclude entries with “0”, you need to use NULLIF() with function AVG().The syntax is as followsSELECT AVG(NULLIF(yourColumnName, 0)) AS anyAliasName FROM yourTableName;Let us first create a tablemysql> create table AverageDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > StudentName varchar(20),    - > StudentMarks int    - > ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into AverageDemo(StudentName, StudentMarks) values('Adam', NULL); Query OK, 1 row affected (0.12 sec) mysql> insert into AverageDemo(StudentName, StudentMarks) values('Larry', 23); Query OK, ... Read More

JSP Page Redirection

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

429 Views

Page redirection is generally used when a document moves to a new location and we need to send the client to this new location. This can be because of load balancing, or for simple randomization.The simplest way of redirecting a request to another page is by using sendRedirect() method of response object. Following is the signature of this method −public void response.sendRedirect(String location) throws IOExceptionThis method sends back the response to the browser along with the status code and new page location. You can also use the setStatus() and the setHeader() methods together to achieve the same redirection example −.... ... Read More

MonthDay toString Method in Java

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

187 Views

The string value of the MonthDay object can be obtained using the method toString() in the MonthDay class in Java. This method requires no parameters and it returns the string value of the MonthDay object.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { MonthDay md = MonthDay.parse("--02-22"); System.out.println("The MonthDay is: " + md.toString()); } }OutputThe MonthDay is: --02-22Now let us understand the above program.The string value of the MonthDay ... Read More

LongStream.Builder build Method in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

139 Views

The build() method of the LongStream.Builder class builds the stream, transitioning this builder to the built state.The syntax is as followsLongStream build()To use the LongStream.Builder class in Java, import the following packageimport java.util.stream.LongStream;The following is an example to implement LongStream.Builder build() method in JavaExample Live Demoimport java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream.Builder builder = LongStream.builder(); builder.accept(255L); builder.accept(570L); builder.accept(355L); builder.accept(155L); ... Read More

Advertisements