Add Line Break for UILabel in iOS

George John
Updated on 29-Jun-2020 13:52:56

3K+ Views

Line break in a UILabel is used to change how the text appears on a label. Suppose a label has text more than two lines but by default the Line break in a UILabel is used to change how the text appears on a label. Suppose a label has text more than two lines but by default the label shows 1 line and wraps/ trims the text that’s more than the label size.This can be done in multiple ways. Three of them are mentioned below.On the storyboard add a label.Give top constraint, trailing and leading constraint.Method One − Editing with ... Read More

Use StringBuilder Class in Android

Nishtha Thakur
Updated on 29-Jun-2020 13:51:54

2K+ Views

Before getting into an example, we should know what string builder is. StringBuilder class is used to create a mutable string and it is not thread safe so multiple thread can access string builder class at a time. This example demonstrate about How to use string Builder class 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 ... Read More

Remove a Specific Element from a LinkedList in Java

Chandu yadav
Updated on 29-Jun-2020 13:51:29

4K+ Views

A specific element in the LinkedList can be removed using the java.util.LinkedList.remove() method. This method removes the specified element the first time it occurs in the LinkedList and if the element is not in the LinkedList then no change occurs. The parameter required for the LinkedList.remove() method is the element to be removed.A program that demonstrates this is given as follows.Example Live Demoimport java.util.LinkedList; public class Demo {    public static void main(String[] args) {       LinkedList l = new LinkedList();       l.add("Apple");       l.add("Mango");       l.add("Pear");       l.add("Orange");     ... Read More

Use String Buffer in Android

Anvi Jain
Updated on 29-Jun-2020 13:51:26

851 Views

Before getting into example, we should know what string buffer is. StringBuffer class is used to create mutable string and it is thread safe. This example demonstrate about How to use string buffer 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 edittext, button and textviews. When user click on button, it ... Read More

Iterate Through a LinkedList in Reverse Direction Using a ListIterator in Java

Ankith Reddy
Updated on 29-Jun-2020 13:49:56

917 Views

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in a LinkedList. The method hasPrevious( ) in ListIterator returns true if there are more elements in the LinkedList while traversing in the reverse direction and false otherwise. The method previous( ) returns the previous element in the LinkedList and reduces the cursor position backward.A program that demonstrates this is given as follows.Example Live Demoimport java.util.LinkedList; import java.util.List; import java.util.ListIterator; public class Demo {    public static void main(String[] args) {       List l = new LinkedList();       ... Read More

Obtain Previous and Next Index in ArrayList Using ListIterator in Java

Arjun Thakur
Updated on 29-Jun-2020 13:48:53

1K+ Views

The previous index and next index in an ArrayList can be obtained using the methods previousIndex() and nextIndex() respectively in the ListIterator Interface.The previousIndex() method returns the index of the element that is returned by the previous() method while the nextIndex() method returns the index of the element that is returned by the next() method. Neither of these methods require any parameters.A program that demonstrates this is given as followsExample Live Demoimport java.util.ArrayList; import java.util.ListIterator; public class Demo {    public static void main(String[] args) {       ArrayList aList = new ArrayList();       aList.add("Amy");       ... Read More

Ways to Increment a Character in Python

Hafeezul Kareem
Updated on 29-Jun-2020 13:48:16

12K+ Views

In this tutorial, we are going to see different methods to increment a character in Python.TypecastingLet's first see what happens if we add an int to char without typecasting.Example Live Demo## str initialization char = "t" ## try to add 1 to char char += 1 ## gets an errorIf you execute above program, it produces the following result −TypeError          Traceback (most recent call last) in ()       3     4 ## try to add 1 to char ----> 5 char += 1 ## gets an error TypeError: must be str, not intTo ... Read More

Remove Element from ArrayList Using ListIterator in Java

Chandu yadav
Updated on 29-Jun-2020 13:48:11

1K+ Views

An element can be removed from an ArrayList using the ListIterator method remove(). This method removes the current element in the ArrayList. If the remove() method is not preceded by the next() method, then the exception IllegalStateException is thrown.A program that demonstrates this is given as follows.Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; public class Demo {    public static void main(String[] args) {       ArrayList aList = new ArrayList();       aList.add("Apple");       aList.add("Mango");       aList.add("Guava");       aList.add("Orange");       aList.add("Peach");       System.out.println("The ArrayList elements are: ");     ... Read More

Compare Strings in Android

Nishtha Thakur
Updated on 29-Jun-2020 13:48:03

2K+ Views

This example demonstrate about How to use compare string 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 edittext, button and textviews. When user click on button, it will take the data from edittext and manipulate with string with string comparing techniques. The result of manipulation data append to textview’sStep 3 − Add the following code ... Read More

Get Thread Group Information in Android

Anvi Jain
Updated on 29-Jun-2020 13:47:36

288 Views

Before getting into an example, we should know what thread is. A thread is a lightweight sub-process, it going to do background operations without interrupt to ui. This example demonstrate about How to get thread group information 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 textview. It contains information about current thread group information.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; ... Read More

Advertisements