George John has Published 1299 Articles

What are intent-filters in Android?

George John

George John

Updated on 30-Jun-2020 05:29:17

An intent filter is an instance of the IntentFilter class. Intent filters are helpful while using implicit intents, It is not going to handle in java code, we have to set it up in AndroidManifest.xml. Android must know what kind of intent it is launching so intent filters give the ... Read More

Loop through an ArrayList using an Iterator in Java

George John

George John

Updated on 29-Jun-2020 13:56:42

An Iterator can be used to loop through an ArrayList. The method hasNext( ) returns true if there are more elements in ArrayList and false otherwise. The method next( ) returns the next element in the ArrayList and throws the exception NoSuchElementException if there is no next element.A program that ... Read More

How to add line break for UILabel in iOS/iPhone?

George John

George John

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

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 ... Read More

Iterate through an ArrayList using a ListIterator in Java

George John

George John

Updated on 29-Jun-2020 13:50:43

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in an ArrayList.The method hasNext( ) in ListIterator returns true if there are more elements in the ArrayList while traversing in the forward direction and false otherwise. The method next( ) ... Read More

Replace an element in an ArrayList using the ListIterator in Java

George John

George John

Updated on 29-Jun-2020 13:47:32

An element in ArrayList can be replaced using the ListIterator method set(). This method has a single parameter i.e. the element that is to be replaced and the set() method replaces it with the last element returned by the next() or previous() methods.A program that demonstrates this is given as ... Read More

Get the index of a particular element in an ArrayList in Java

George John

George John

Updated on 29-Jun-2020 13:41:33

The index of a particular element in an ArrayList can be obtained by using the method java.util.ArrayList.indexOf(). This method returns the index of the first occurance of the element that is specified. If the element is not available in the ArrayList, then this method returns -1.A program that demonstrates this ... Read More

Check existence of an element in Java ArrayList

George John

George John

Updated on 29-Jun-2020 13:38:45

The java.util.ArrayList.contains() method can be used to check if an element exists in an ArrayList or not. This method has a single parameter i.e. the element whose presence in the ArrayList is tested. Also it returns true if the element is present in the ArrayList and false if the element ... Read More

Iterate through ArrayList in Java

George John

George John

Updated on 29-Jun-2020 13:36:44

The iterator can be used to iterate through the ArrayList wherein the iterator is the implementation of the Iterator interface. Some of the important methods declared by the Iterator interface are hasNext() and next().The hasNext() method returns true if there are more elements in the ArrayList and otherwise returns false. ... Read More

Traverse TreeSet elements in descending order in java

George John

George John

Updated on 29-Jun-2020 13:26:15

Create TreeSet and add elements to itTreeSet tSet = new TreeSet(); tSet.add("P"); tSet.add("Q"); tSet.add("R"); tSet.add("S");Now, let us traverse elements in descending orderIterator j = tSet.descendingIterator(); while(j.hasNext()) {    System.out.println(j.next()); }The following is an example to traverse TreeSet elements in descending orderExample Live Demoimport java.util.*; public class Demo {    public static ... Read More

Get first value in Java TreeSet

George John

George John

Updated on 29-Jun-2020 13:23:53

To get the first value in TreeSet, use the first() method.First, get the TreeSet and add elements to itTreeSet tSet = new TreeSet(); tSet.add("10"); tSet.add("20"); tSet.add("30"); tSet.add("40"); tSet.add("50"); tSet.add("60");Now, get the first valuetSet.first()The following is an example to get the first value in TreeSetExample Live Demoimport java.util.*; public class Demo { ... Read More

Previous 1 ... 3 4 5 6 7 ... 130 Next
Advertisements