Answer:
- import java.util.ArrayList;
- public class Main {
-
- public static void main(String[] args) {
- ArrayList<String> strList =new ArrayList<String>();
- strList.add("to");
- strList.add("be");
- strList.add("or");
- strList.add("not");
- strList.add("to");
- strList.add("be");
- strList.add("hamlet");
-
- swapPairs(strList);
- System.out.println(strList);
- }
-
- public static void swapPairs(ArrayList<String> list){
- for(int i=0; i < list.size()-1; i+=2){
- String temp = list.get(i);
- list.set(i, list.get(i+1));
- list.set(i+1, temp);
- }
- }
- }
Explanation:
Firstly, let's create a method swapPairs that take one ArrayList (Line 18). In the method, use a for-loop to traverse through each item in the ArrayList and swap the items between the current items at index-i and at index-i+1 (Line 19-22). The index-i is incremented by two in next loop and therefore the next swapping will proceed with third and fourth items and so forth.
In the main program, create a sample ArrayList (Line 5-12) and then test the method (Line 14) and print the output (Line 15). We shall get [be, to, not, or, be, to, hamlet].
Answer:
java
Explanation:
Java es rápido, seguro y fiable. Desde ordenadores portátiles hasta centros de datos, desde consolas para juegos hasta computadoras avanzadas, desde teléfonos móviles hasta Internet, Java está en todas partes. Si es ejecutado en una plataforma no tiene que ser recompilado para correr en otra. Java es, a partir de 2012, uno de los lenguajes de programación más populares en uso, particularmente para aplicaciones de cliente-servidor de web
Answer:
b. 16
Explanation:
The given PHP code segment consists of 2 statements.
$str="The quick brown fox jumps over the lazy dog";
This defines a variable $str and assigns the given text to it.
echo strpos($str,'fox');
This statement prints the location of 'fox' in the text associated with the variable $str.
Upon execution it will print the value 16 which corresponds to the position of 'fox' in the given sentence.
<span>One system of lens - ocular microscope
Two systems of lens - compound microscope
Some of the parts of a compound microscope are the </span>eyepiece lens.<span> There are two knobs on under the other to one side of the microscope which are used for </span>Coarse focus and Fine focus. There is an illuminator<span> at the bottom of the microscopic stand, which sheds a powerful light on the subject under the lens. Other parts include </span>objective lenses<span>, </span>stage with stage clips<span> (where the subject is placed) and r</span>evolving nosepiece. The tube<span> connects the eyepiece lens to the </span>turret<span>.</span>