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
Air enters a compressor at 100 kPa and 25 ⁰C. It is compressed to 2 MPa and exits the compressor at 540 K. The compressor is at
AysviL [449]

Answer:

(a) The reversible work is 207 kJ/kg

(b) The irreversibility rate is -38.39 kJ/kg

Explanation:

State1 : p1 = 100kpa, T1= 25+273 =298k

From air table, h1 =298.18 kJ/kg, s10= 1.69528 kJ/kgK

State 2a:p2=2mpa,t2=540k (actual condition 2a)

h2a= 544.35 kJ/kg,s2a0=2.29906

actual work input to the compressor =wout=h1-h2+Qin

=298.18-544.35+(-150)kJ/kg(- sign indicate heat loss)

=(-246.17)kJ/kg(-ve sign indicates the work is given into the system

a) Reversible work= Win actual - any irreversiblities present

                             =246.17 + irreversibilty

b) irreversibility = T0(Entopy generation Sgen) for air, Sgen

                         =s20-s10-Rln(p2/p1), T0=250C

                         =(25+273)(s2a0-s10-Rlnp2/p1+Qout/Tsurr)

    = 298x[(2.29906-1.69528-0.287kJ/kgK xln(2000kpa/100) + 150 /298]

  = -38.39 kJ/kg

a)Reversible work = Win actual -any irreversiblities present                  

                           =246.17 + irreversibilty

                           =246.17+-38.39

                          =207 kJ/kg

8 0
3 years ago
What is substructure work?
o-na [289]
The answer is: Work below ground level.
5 0
3 years ago
Calculate the LER for the rectangular wing from the previous question if the weight of the glider is 0.0500 Newton’s.
lapo4ka [179]

Answer:

0.2

Explanation:

Since the span and chord of the rectangular wing is missing, due to it being from the other question, permit me to improvise, or assume them. While you go ahead and substitute the ones from your question to it, as it's both basically the same method.

Let the span of the rectangular wing be 0.225 m

Let the chord of the rectangular wing be 0.045 m.

Then, the area of any rectangular chord is

A = chord * span

A = 0.045 * 0.225

A = 0.010 m²

And using the weight of the glider given to us from the question, we can find the LER for the wing.

LER = Area / weight.

LER = 0.010 / 0.05

LER = 0.2.

Therefore, using the values of the rectangular wing I adopted, and the weight of the glider given, we can see that the LER of the glider is 0.2

Please mark brainliest...

3 0
3 years ago
Read 2 more answers
A DC generator turns at 2000 rpm and has an output of 200 V. The armature constant is 0.5 V-min/Wb, and the field constant of th
WITCHER [35]

Answer:

b. 10A

Explanation:

Using the formula, E= k × r×I

200= 0.5 ×2000×0.02×I

200=20×I

Dividing with 20

I = 200/20= 10A

4 0
3 years ago
Read 2 more answers
The way most recursive functions are written, they seem to be circular at first glance, defining the solution of a problem in te
EastWind [94]

Question Continuation

int factorial(int n) {

if(n == 0)

return 1;

else

return n * factorial(n - 1);

}

Provide a brief explanation why this recursive function works.

Show all steps involved in calculating factorial(3) using the function defined.

Answer:

1. Brief explanation why this recursive function works.

First, the recursive method factorial is defined.

This is the means through with the machine identifies the method.

The method is defined as integer, the machine will regard it as integer.

When the factorial is called from anywhere that has access to it, which in this case is within the factorial class itself. This means you can call it from the main method, or you can call it from the factorial method itself. It's just a function call that, well, happens to call itself.

2. Steps to calculate factorial(3)

1 First, 3 is assigned to n.

2. At line 2, the machine checks if n equals 0

3. If yes, the machine prints 1

4. Else; it does the following from bottom to top

factorial(3):

return 3*factorial(2);

return 2*factorial(1):

return 1;

Which gives 3 * 2 * 1 = 6

5. Then it prints 6, which is the result of 3!

6 0
3 years ago
Other questions:
  • Explain the advantages of continuous insulation in envelope assemblies and why it is better to have the continuous insulation on
    12·1 answer
  • A gas is compressed from an initial volume of 0.42 m3 to a final volume of 0.12 m3. During the quasi-equilibrium process, the pr
    14·1 answer
  • Consider a fully-clamped circular diaphragm poly-Si with a radius of 250 μm and a thickness of 4 μm. Assume that Young’s modulus
    14·1 answer
  • Fin efficiency is defined in relation to the maximum possible heat transfer rate from the fin for given convective conditions. T
    10·1 answer
  • A hollow aluminum alloy [G = 3,800 ksi] shaft having a length of 12 ft, an outside diameter of 4.50 in., and a wall thickness of
    8·1 answer
  • If gas costs $3.50 per gallon, how much would it cost to drive 500 miles in a city in a car that is 58.3 km/L
    13·1 answer
  • What are examples of Energy careers? Check all that apply. Carpenter Video Editor Electrical Power-Line Installer Printing Press
    15·2 answers
  • PLEASE PLEASE PLEASE HELP
    9·1 answer
  • The cantilevered W530 x 150 beam shown is subjected to a 9.8-kN force F applied by means of a welded plate at A. Determine the e
    15·1 answer
  • Write a SELECT statement that returns these four columns:
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!