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
BE-40 What is a characteristic of a catamaran hull?
Nat2105 [25]

Answer:

<em>A stable ride</em>

Explanation:

A Catamaran hull is a form of sea craft invented by the Austronesian peoples, the invention of the Catamaran hull enabled these people to sail across the sea in their expansion to the islands of the Indian and Pacific Oceans. Catamaran has multiple hulls, usually two parallel hulls of equal size. This geometric feature gives the craft an increased stability because,<em> it derives extra stability from its wide beam, in the place of a ballasted keel employed in a regular monohull sailboat. </em>A Catamaran hull will require four times the force needed to capsize it, when compared to an equivalent monohull.

8 0
3 years ago
Which of the following is not a task electricians typically do when maintaining a building’s electrical system?
Scorpion4ik [409]

Answer:replace insulation to help control...

Explanation:

Thats a insulation workers job

4 0
3 years ago
An asphalt concrete mixture includes 94% aggregates by weight. The specific gravity of aggregate and asphalt are 2.7 and 1.0, re
riadik2000 [5.3K]

Answer:

The correct solution is "5.74%".

Explanation:

The given values are:

Gravity of aggregate,

G_{agg}=2.7

Gravity of asphalt,

G_{asp}=1.0

Asphalt concrete mixture,

W_{agg}=0.94 \ W_m

We know that,

W_{asp}=W_m-W_{agg}

        =0.06 \ W_m

Now,

The theoretical specific gravity of mix,

⇒ G_t=\frac{W_{agg}+W_{asp}}{\frac{W_{agg}}{G_{agg}} +\frac{W_{asp}}{G_{asp}} }

By putting the values, we get

         =\frac{0.94 \ Wm+0.06 \ Wm}{\frac{0.94 \ Wm}{2.7} +\frac{0.06 \ Wm}{1} }

         =2.45

hence,

The percentage of voids will be:

⇒  %V = \frac{G_t-G_m}{G_t}\times 100

           = \frac{2.45-2.317}{2.45}\times 100

           = \frac{0.133}{2.317}\times 100

           = 5.74 (%)  

8 0
3 years ago
A sprinter reaches his maximum speed in 2.5sec from rest with constant acceleration. He then maintains that speed and finishes t
liubo4ka [24]

The maximum Speed of the Sprinter from the velocity time graph of his motion is; 11.98 m/s

<h3>How to find the maximum speed?</h3>

We are given;

Initial Speed; u = 2.5 s

Total distance; d = 100 m

Total time; T = 9.6 s

The total distance is;

d = ¹/₂(9.6 + (9.6 - 2.5) * v

where v is maximum speed.

Thus;

¹/₂(9.6 + (9.6 - 2.5) * v = 100

16.7v = 200

v = 200/16.7

v = 11.98 m/s

Read more about Maximum Speed at; brainly.com/question/4931057

#SPJ1

3 0
2 years ago
Public transport is a generic term used to describe the family of transit services available to
Softa [21]

Answer:

true

Explanation:

it is used to describe the family of transit services available to residents of urban area

5 0
3 years ago
Other questions:
  • Heather is troubleshooting a computer at her worksite. She has interviewed the computer’s user and is currently trying to reprod
    11·1 answer
  • For the speed equation along centerline of a diffuser, calculate the fluid acceleration along the diffuser centerline as a funct
    5·2 answers
  • How dose iorn get forged itno steel?
    10·1 answer
  • A 25-W compact fluorescent lightbulb (CFL) produces the light equivalent of a 100-W incandescent bulb. The population of North A
    14·1 answer
  • A mixture of two gases has a total mass of 80 kg. One gas has a specific volume of 0.8 m^3/kg and occupies a volume of 40 m^3. T
    7·1 answer
  • An air-standard Diesel cycle has a compression ratio of 16 and a cutoff ratio of 2. At the beginning of the compression process,
    12·1 answer
  • The switch has been in position a for a long time. At t = 0, the switch moves from position a to position b. The switch is a mak
    11·1 answer
  • Which of the following describes what a manufacturing engineer does
    9·2 answers
  • Which color is used to indicate that a wire will be energized when power is brought to the circuit
    13·1 answer
  • Select the best answer for the question
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!