1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mamont248 [21]
3 years ago
10

Write a program that adds the numbers 1 through 5 into the numbers ArrayList and then prints out the first element in the list.

Engineering
1 answer:
nekit [7.7K]3 years ago
6 0

Answer:

Answer code is given below along with comments to explain each step

Explanation:

Method 1:

// size of the array numbers to store 1 to 5 integers

int Size = 5;  

// here we have initialized our array numbers, the type of array is integers and size is 5, right now it is empty.

ArrayList<Integer> numbers = new ArrayList<Integer>(Size);

// lets store values into the array numbers one by one

numbers.add(1)

numbers.add(2)

numbers.add(3)

numbers.add(4)

numbers.add(5)

// here we are finding the first element in the array numbers by get() function, the first element is at the 0th position

int firstElement = numbers.get(0);

// to print the first element in the array numbers

System.out.println(firstElement);  

Method 2:

int Size = 5;  

ArrayList<Integer> numbers = new ArrayList<Integer>(Size);

// here we are using a for loop instead of adding manually one by one to store the values from 1 to 5

for (int i = 0; i < Size; i++)  

{

// adding the values 1 to 5 into array numbers

  numbers.add(i);  

}

//here we are finding the first element in the array numbers

int firstElement = numbers.get(0);  

// to print the first element in the array

System.out.println(firstElement);  

You might be interested in
Is there a way to get the answers to a NCCER book test?
sergeinik [125]

Answer:

go on google and type NCEER book answers

3 0
3 years ago
Technician A says that the use of methanol in internal combustion engines has declined over the years. Technician B says that th
enyata [817]

Answer:

Both Technician A and B are correct

Explanation:

Methanol is used in internal combustion engines. However, the use of methanol in internal combustion engines has decreased lately even though it was thought to lead to cleaner emissions than gasoline. Methanol internal combustion engines produce formaldehyde which is also an environmental pollutant. Also, the cost of methanol is slightly higher than that of good quality gasoline.

MTBE replaced tetraethyllead as a gasoline additive because the former lead to the emission of particulate lead from automobile exhausts which is a serious environmental pollutant. The use of MTBE has declined over the years due to environmental concerns. It has been banned because it has been found to be a significant groundwater pollutant if gasoline containing MTBE is spilled or leaked at gas stations.

4 0
3 years ago
In multi-grade oil what is W means?
irga5000 [103]

Answer:

winter viscosity grades

Explanation:

The “W”/winter viscosity grades describe the oil's viscosity under cold temperature engine starting conditions. There's a Low Temperature Cranking Viscosity which sets a viscosity requirement at various low temperatures to ensure that the oil isn't too thick so that the starter motor can't crank the engine over.

4 0
3 years ago
The acceleration (in m/s^2) of a linear slider (undergoing rectilinear motion) within a If the machine can be expressed in terms
Inga [223]

Answer:

47.91 sec

Explanation:

it is given that \alpha =\frac{1}{4v^{2}}

at t=0 velocity =0 ( as it is given that it is starting from rest )

we have to find time at which velocity will be 3.3 \frac{m}{sec^{2}}

we know that \alpha =\frac{dv}{dt}=\frac{1}{4v^{2}}

4v^{2}dv=dt

integrating both side

\frac{4v^{3}}{3}=t+c---------------eqn 1

at t=o it is given that v=0 putting these value in eqn 1 c=0

so \frac{4v^{3}}{3}=t

when v=  3.3 \frac{m}{sec^{2}}

t=\frac{4}{3}\times 3.3^{3}

=47.91 sec

6 0
4 years ago
W²-5w+14
alexira [117]

Answer:w²-5w+14

4x²+11x+16

6x²+7x-10

x²-16x+56

Explanation:

7 0
3 years ago
Other questions:
  • A column has a 4.8 cm by 8.7 cm rectangular cross section and a height 4 mm . The column is fixed at both ends and has a lateral
    6·1 answer
  • Kjhwe ,kenwif ujwfeowlwfwfwfw...
    14·2 answers
  • A structural component in the form of a wide plate is to be fabricated from a steel alloy that has a plane-strain fracture tough
    10·1 answer
  • . A piston-cylinder device whose piston is resting on top of a set of stops initially contains 0.5 kg of helium gas at 100 kPa a
    14·1 answer
  • B1) 20 pts. The thickness of each of the two sheets to be resistance spot welded is 3.5 mm. It is desired to form a weld nugget
    8·1 answer
  • All of the following are categories for clutch covers except
    11·1 answer
  • Drag each label to the correct location on the chart. Classify the organisms based on how they obtain food.
    14·2 answers
  • 6
    10·2 answers
  • A) If a given directional antenna can receive 15 times the power of an isotropic antenna, what is
    11·1 answer
  • Key term of Bimetal strip
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!