Found 34486 Articles for Programming

What is search view in android?

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

172 Views

Before getting into searchview example, we should know what is search view in android, search view is just like search box in HTML. we can search anything from particular list items.This example demonstrate about how to integrate search view 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 are giving search view and listview because search view going to search element from ... Read More

Different ways to format long with Java System.out.format

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

357 Views

The System.out.format is used in Java to format output. Here, let’s say the following is our long. long val = 787890; To format, we have considered the following that justifies the output. System.out.format("%d%n", val); System.out.format("%9d%n", val); System.out.format("%+9d%n", val); System.out.format("%08d%n", val); System.out.format("%, 9d%n", val); The following is the complete example that displays the difference in output as well. Example Live Demo import java.util.Locale; public class Demo { public static void main(String []args) { long val = 787890; System.out.format("%d%n", val); ... Read More

Compare Two Java long Arrays

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

417 Views

To compare two Java long arrays in Java, use Arrays.equals() method. Let’s say we have the following long arrays. long[] arr1 = new long[] { 767, 568, 555, 897, 678 }; long[] arr2 = new long[] { 456, 756, 555, 999, 678}; long[] arr3 = new long[] { 767, 568, 555, 897, 678 }; Now, we can compare the equality of these arrays using the equals() method. Arrays.equals(arr1, arr2); Arrays.equals(arr2, arr3); Arrays.equals(arr1, arr3); The following is the complete example. Example Live Demo import java.util.*; public class Demo { public ... Read More

NavigationView in ActionBar in Android

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

839 Views

Before getting into the Navigation view example, we should know about navigation view. Navigation view is just like a sliding menu in HTML. Navigation view is extended by navigatoin drawer. Most of use cases of Navigation view is used to redirect different activities or show profile information.This example demonstrate about how to integrate NavigationView in ActionBarStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step2 − While creating project we should select Navigation drawer activity as shown belowAfter selecting navigation drawer activity click on ... Read More

Java program to Sort long Array

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

1K+ Views

To sort long array in Java, use the Arrays.sort() method. Let’s say the following is our long array. long[] arr = new long[] { 987, 76, 5646, 96, 8768, 8767 }; To sort the above long array is an easy task in Java. Use the following method. Arrays.sort(arr); After that, print the array and you can see that it is sorted. for (long l : arr) { System.out.println(l); } The following is the complete example. Example Live Demo import java.util.*; public class Demo { public static ... Read More

Loading Image using Glide in Android

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

4K+ Views

Before getting into Glide example, we should know what is glide, Glide is an image processing library developed by muyangmin. Using glide library we can show image, decode images, cache images, animated gifs and many more.This example demonstrate about how to integrate glide 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 in build.gradle(Module:app).apply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {       applicationId "com.example.andy.myapplication"       minSdkVersion 15       ... Read More

Intersection of two arrays in Java

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

2K+ Views

The intersection of the two arrays results in those elements that are contained in both of them. If an element is only in one of the arrays, it is not available in the intersection. An example of this is given as follows − Array 1 = 1 2 5 8 9 Array 2 = 2 4 5 9 Intersection = 2 5 9 A program that demonstrates the intersection of two sorted arrays in Java is given as follows. Example Live Demo public class Example { public static void main(String args[]) ... Read More

Java program to check if binary representation is palindrome

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

3K+ Views

A palindrome is a sequence that is same both forwards and backwards. The binary representation of a number is checked for being a palindrome but no leading 0’s are considered. An example of this is given as follows − Number = 5 Binary representation = 101 The binary representation of 5 is a palindrome as it is the same both forwards and backwards. A program that demonstrates this is given as follows. Example Live Demo public class Example { public static void main(String argc[]) { long num ... Read More

How to add picasso library in android studio?

Ankith Reddy
Updated on 27-Jan-2020 13:10:23

975 Views

Before getting into picasso library example, we should know about picasso. Picasso is image processing library and developed by Square Inc. In older days we used to write lengthy of codes to grab image from server or do process., to optimize the process picasso introduced.This example demonstrate about how to integrate picasso library in android studio.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 in build.gradle.apply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {   ... Read More

Java Program to concatenate a String and Integers

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

8K+ Views

To concatenate a String and some integer values, you need to use the + operator. Let’s say the following is the string. String str = "Demo Text"; Now, we will concatenate integer values. String res = str + 1 + 2 + 3 + 4 + 5; The following is the final example. Example Live Demo public class Demo { public static void main(String[] args) { String str = "Demo Text"; System.out.println("String = "+str); String res = str + 1 + 2 + 3 + 4 + 5; System.out.println(res); } } Output String = Demo Text Demo Text12345

Advertisements