Found 34494 Articles for Programming

NavigationView in ActionBar in Android

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

838 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

973 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

how can I design custom toast message in Android?

Arjun Thakur
Updated on 26-Jun-2020 05:26:43

853 Views

Before getting into Custom Toast, we should know about what is toast. Toast is used to display message on current screen for sometime. After some time it doing to disappear. In this example we can learn how to customize toast message.This example demonstrate about how to create custom toast message 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.               Step 3 − Add the following ... Read More

Java program to find all duplicate characters in a string

karthikeya Boyini
Updated on 10-Jul-2024 17:48:30

42K+ Views

The duplicate characters in a string are those that occur more than once. These characters can be found using a nested for loop. Problem Statement Given a Java program to find the duplicate character in a given string. Input String = Tutorialspoint Output Duplicate Characters in above string are: t o i In the above string, t o i are duplicate characters as it occurs more than once. Approach to find all duplicate characters in a string Below are the steps to find all duplicate characters in a string − ... Read More

Java program for removing n-th character from a string

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

533 Views

The n-th character from a string can be removed using the substring() function. An example of this is given as follows − String = Happy The 3rd character is removed = Hapy A program that demonstrates this is given as follows − Example Live Demo public class Example { public static void main(String args[]) { String str = "Apple"; System.out.println("Original string: " + str ); System.out.println("String with 4th character removed: " + removeChar(str, 4)); ... Read More

Advertisements