Difference Between Parcelable and Serializable in Android

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

4K+ Views

This example demonstrates about Difference between Parcel able and Serializable in androidSerializableSerializable is a markable interface or we can call as an empty interface. It doesn’t have any pre-implemented methods. Serializable is going to convert an object to byte stream. So the user can pass the data between one activity to another activity. The main advantage of serializable is the 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) {     ... Read More

MySQL Query to Show Tables in Sorted Order

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

141 Views

Use INFORMATION_SCHEMA.TABLES to display tables in sorted order. The below syntax will give sorted list of tables in ascending order:select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA= 'yourDatabaseName' order by TABLE_NAME;Following is the query to implement the equivalent to SHOW TABLES:mysql> select TABLE_NAME from INFORMATION_SCHEMA.TABLES    -> where TABLE_SCHEMA= 'sample' order by TABLE_NAME;This will produce the following output+------------------------------------+ | TABLE_NAME                         | +------------------------------------+ | a                                  | | accumulateddemo               ... Read More

Get Timezone ID Strings in Java

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

225 Views

Let us get the timezone id strings for timezone America. For this, use the get.AvailableZoneIds() method −ZoneId.getAvailableZoneIds().stream().filter(s ->s.startsWith("America")) .forEach(System.out::println);With that, we have used the forEach to display all the timezones in America −America/Cuiaba America/Marigot America/El_Salvador America/Guatemala America/Belize America/Panama America/Managua America/Indiana/Petersburg America/Chicago America/Tegucigalpa America/Eirunepe America/Miquelon . . .Exampleimport java.time.ZoneId; public class Demo {    public static void main(String[] args) {       System.out.println("TimeZones in the US");       ZoneId.getAvailableZoneIds().stream().filter(s ->s.startsWith("America"))       .forEach(System.out::println);    } }OutputTimeZones in the US America/Cuiaba America/Marigot America/El_Salvador America/Guatemala America/Belize America/Panama America/Managua America/Indiana/Petersburg America/Chicago America/Tegucigalpa America/Eirunepe America/Miquelon America/Argentina/Catamarca America/Grand_Turk America/Argentina/Cordoba America/Araguaina America/Argentina/Salta America/Montevideo America/Manaus ... Read More

C++ Program to Perform Optimal Parenthesization Using Dynamic Programming

Smita Kapse
Updated on 30-Jul-2019 22:30:25

203 Views

This is a C++ program to perform Optimal Paranthesization using Dynamic Programming.AlgorithmBegin    Take the length n and dimension of matrix as input.    MatrixChain() to find out minimum multiplications:    Arguments:       a[i][j]=Minimum number of scalar multiplications needed to          compute the matrix A[i]A[i+1]...A[j] = A[i..j] where dimension of A[i] is p[i-1] x p[i].          a[i][j] means cost is zero when multiplying one matrix.       L is chain length.       m = cost / scalar multiplications.    Body of the function:       for i = ... Read More

Order By Date and Integer Column in MySQL

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

202 Views

You can achieve this with the help of ORDER BY CASE statement. The syntax is as follows −SELECT *FROM yourTableName ORDER BY CASE yourIntegerColumnName1 WHEN 2 THEN 1 ELSE 0 END DESC ,yourDateColumnName ASC;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OrderByCaseDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> GroupId int,    -> ArrivalDate date,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (1.57 sec)Insert some records in the table using insert command. The query is as ... Read More

ShortBuffer compareTo Method in Java

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

109 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.ShortBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater than the given buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo { public static void main(String[] args) { int n = 5; try { ... Read More

Iterate Through Java Unit Tuple

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

233 Views

The iteration through Unit in JavaTuples is like what you may have seen in Java Arrays collection.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Unit 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.Unit; public class Demo {    public static void main(String[] ... Read More

Set Fit WebView Screen in Android

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

3K+ Views

This example demonstrate about How to set fit webview screen in android.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 tutorialspoint.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.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    @RequiresApi(api = ... Read More

Codepoints Method in Java IntStream

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

413 Views

The codePoint() method is used to display a stream of code point values from the given sequence.The syntax is as followsIntStream codePoints()To work with Java IntStream class, you need to import the following packageimport java.util.stream.IntStream;Here is our stringString myStr = "Example!";Now, get the code point valuesIntStream intStream = myStr.codePoints();The following is an example to implement codePoints() method in Java IntStreamExample Live Demoimport java.util.stream.IntStream; public class Demo {    public static void main(String args[]) {       String myStr = "Example!";       IntStream intStream = myStr.codePoints();       System.out.println("The following is the list of ASCII Values for the ... Read More

Create Key-Value Tuple from Another Collection in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

87 Views

To create KeyValue tuple from another collection, use the fromCollection() method. We will be creating the tuple from List collection. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package.import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe following ... Read More

Advertisements