Found 33676 Articles for Programming

Java Program to concatenate a String and Integers

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

9K+ 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

1K+ 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

Shriansh Kumar
Updated on 01-Aug-2024 10:46:49

65K+ Views

The duplicate characters in a string are those that occur more than once. In Java, String is a non-primitive datatype that contains one or more characters and is enclosed in double quotes(“ ”). As per the problem statement, we are given a string and our task is to write a Java program to find all the duplicate characters from that string. We can use for loop and nested for loop to solve this given problem. Example Scenario Input: String str = "Apple"; Output: duplicate_char = p; p is a duplicate character as it occurs more than once. Using ... Read More

Java program for removing n-th character from a string

Samual Sam
Updated on 24-Sep-2024 21:44:16

911 Views

In this article, we will learn how to remove the n-th character from a string in Java. The program takes an input string and an index, removes the character at the given index, and returns the modified string and this process will be demonstrated through a simple example, using the substring() method. Problem Statement Write a program in Java that removes the n-th character from a given string. The program will display the original string and the string after the character is removed − Input Original string: Apple Output String with 4th character removed: Appe Steps to remove n-th character from ... Read More

How to Speed up Gradle build process in Android Studio?

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

279 Views

Before getting info speed up gradle build, we should know that, what is gradle build.Before eclipse, we dont have any automation scripts to build java and XML code to android apk. So that we used commands to generate apk. To optimize this process, gradle build come into the picture. Gradle is automated script to build and generate apk using android studio. What is Gradle sync ? Gradle sync is automation process to download dependencies which are declare in gradle file. A simple example as shown below − How to speed Gradle Build in android? Step 1 − Open gradle.properties ... Read More

How to create custom actionbar in android?

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

4K+ Views

Before getting into example we should know what is action bar in android. Action bar just like header in android. Either we can use same action bar for all screen or we can change action bar for particular activity.This example demonstrate about how to create a custom action bar 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 2 − Add the following code to src/MainActivity.javaimport android.os.Bundle; import android.support.v7.app.ActionBar; import ... Read More

Enhancing your logging experience with Timber in Android

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

398 Views

Timber library is a extended library of android Log's. While developing android applications, most of developers prefer Android Logs. But here problem is about clean logs while deploy android project. To avoid this process using Timber library.This example demonstrate about how to integrate Timber 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 Timber library in build.gradle as shown belowapply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {       applicationId "com.example.andy.myapplication"       ... Read More

Can someone give one exact example of webview implementation in android

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

276 Views

Before getting into webview implementation we should know what is webview. Webview is a extended of a view and it is used to show HTML content or web pages.Methods are available in webview.clearHistory() − it is used to clear webview historydestroy() − It is used to destroy internal state of webview.getUrl() −it is used to return current webview url.getTitle() − It is used to return current webview tittle.canGoBack() − It indicates about current webview has back history items.Using webview, it opens webview content in default android browsers. If you want to open inside of application. ShouldOverrideUrlLoading as shown below.private class ... Read More

How to make a ListView in android?

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

4K+ Views

Before getting into listview example, we should know about listview, Listview is a collection of items pulled from arraylist, list or any databases. Most uses of listview is a collection of items in vertical format, we can scroll up/down and click on any item.This example demonstrate about How to make a ListView 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 activity_main.xml, we have declared a ... Read More

How to display a list of images and text in a ListView in Android?

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

6K+ Views

Before getting into listview example, we should know about listview, Listview is a collection of items pulled from arraylist, list or any databases. Most uses of listview is a collection of items in vertical format, we can scroll up/down and click on any item.What is custom listview?Custom listview works based on customAdapter. In this custom adapter we can pass custom object. We are passing subject data to listview as shown below.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 ... Read More

Advertisements