Answer:
//importing package java.util.ArrayList to use ArrayList in the program
import java.util.ArrayList;
import java.util.Date;
public class test_array_list {
// Main method
public static void main(String[] args) {
// Create an array list of objects
ArrayList<Object> s = new ArrayList<Object>();
s.add(new Loan());
s.add(new Date());
s.add(new String("String class"));
s.add(new Circle());
// Display all the elements in the list by
// invoking the object’s to String() method
for (int element = 0; element < o.size(); element++) {
System.out.println((s.get(element)).toString());
}
}
}
Explanation:
The Above code has proper comments to which is self explanatory.
Answer:In order to swap elements of ArrayList with Java collections, we need to use the Collections.swap() method. It swaps the elements at the specified positions in the list.
Declaration −The java.util.Collections.swap() method is declared as follows
public static void swap(List <?> list, int i, int j)
where i is the index of the first element to be swapped, j is the index of the other element to be swapped and list is the list where the swapping takes place.
Explanation:
import java.util.*;
public class Example {
public static void main (String[] args) {
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(10);//0
list.add(20);//1
list.add(30);//2
list.add(40);//3
list.add(50);//4
System.out.println("Original list : " + list);
Collections.swap(list, 4, 0); // swapping element at index 3 i.e. 50 and index 1 i.e. 10
System.out.println("List after swapping : " + list);
}
}
<u>A potentiometer a three wire variable resistor is used in </u><u>Throttle position (TPS) Sensor.</u>
<u />
Explanation:
A <u>potentiomete</u>r is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. In case only two terminals are used, one end and the wiper, it acts as a variable resistor or rheostat.
A<u> throttle position sensor (TPS) </u>is a sensor which is used to monitor the air intake by an engine. This sensor is usually located on the shaft or the butterfly spindle because it can be directly be used to use the position of the <u>THROTTLE</u>
The T<u>hrottle Position Sensor (TPS) is a part of Fuel Management system of a vechile.The proper function of Throttle Position Sensor (TPS) ensures that the right amount of fuel and air is delivered to the vechile engine.</u>
A human-computer interaction