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
morpeh [17]
4 years ago
14

How do you get the value of an element in an array? And how about for an ArrayList?

Computers and Technology
1 answer:
Usimov [2.4K]4 years ago
7 0

Answer:

array: a[21], b[34] etc.

ArrayList: arr.get(12), arr.get(23)

Explanation:

Remember that array is a fixed size collection of values of the same datatypes. We need to provide the array size at the time of the declaration itself. Like:

Student[]=new Student[5];

The above is an array of five student object types.

Similarly, we can have:

a[] =new int[5];

This is an array of five int type.

And we can output the fourth student as Student[4].name, Student[4].marks. And in int case like a[3], a[4], etc.

Similarly, we can get the value from ArrayList as:

arr.get(3);

ArrayList is a resizable array, and can be found inside java.util.ArrayList.

You might be interested in
Given the following snippet of code, answer the following two questions based on the code: typedef enum {Sun, Mon, Tue, Wed, Thu
ANEK [815]

Answer:

1) The value of x will be 6.

2) The value of y will be 7.

Explanation:

1) The value of x will be 6.  

The enum values are labeled by default from 1. This means that Sun = 1, Mon = 2, Tue = 3 and so on.  

So, x = Mon = 2 and y = Sat = 6  

x increases up to y = 6 in the while loop.  

and then y also increments by 1.  

2)So the value of y = 7.  

You will need actual printf("Sun") or printf("Mon") for printing the actual text for the enum.

7 0
3 years ago
3. Maria is in charge of consolidating the names of the participants of the two-day virtual
Lina20 [59]

Answer:

The correct sequence of steps in sorting text is;

III, IV, I and II

Which is option 'C' where the last item is II

C. III, IV, I and II

Explanation:

Sorting is the orderly arrangement of items (data) according to a specified criteria such as arranging a list of items alphabetically or a numerical arrangement of a data collection

Filtering is the selection for display, data that meets a specific condition

To arrange the names of the participants of the two-day virtual seminar alphabetically using MS Excel the sequence of steps are;

1. Select the rows or columns the are to be sorted by using steps for selecting  rows and/or columns

2. Go to the Editing group of the Home Tab ribbon

3. Click on (the down arrow besides) the Sort & Filter command icon to display a drop down menu with options for type of sorting and filtering

4. Choose Sort A to Z to sort the contents of the cell range in increasing alphabetical order

Therefore, the correct sequence of steps are;

III. Select the cell range needed to be sorted

IV. Go to the Editing Styles group of the Home Tab

I. Click the Sort & Filter command. A drop down menu appears

II. Choose Sort A to Z.

The correct sequence is III, IV, I and II.

7 0
3 years ago
What is a computer? ​
miv72 [106K]
<h2><em>what is a computer? </em></h2>

  • <em>A <u>computer</u> is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform generic sets of operations known as programs. These programs enable computers to perform a wide range of tasks. </em>

<em>hope </em><em>it</em><em> helps</em>

<em>#</em><em>c</em><em>a</em><em>r</em><em>r</em><em>y</em><em> </em><em>on</em><em> learning</em>

5 0
3 years ago
Read 2 more answers
) Consider the ambiguous CFG problem: given a context free grammar, does there exist a string that can be generated by two diffe
vodomira [7]

Answer:

See explaination

Explanation:

The post correspondence problem is: Given a_1, \ldots, a_n and b_1, \ldots, b_n , is there a sequence of indices 11. ..., im such that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} .

To reduce from the PCP to the ambiguous CFG problem, do the following. Add some more symbols c_1, \ldots, c_n and define the following languages:

L_{A} = \{a_{i_1}\ldots a_{i_k}c_{i_k}\ldots c_{i_1} \mid k \geq 1\}

L_{B} = \{b_{i_1}\ldots b_{i_k}c_{i_k}\ldots c_{i_1} \mid k \geq 1\}

L_{AB} = L_A \cup L_B .

Define the following grammar for the language L_{AB} :

S \to S_{A} \mid S_{B}

S_A \to a_iS_Ac_i \mid a_ic_i, 1 \leq i \leq n

S_B \to b_iS_Bc_i \mid b_ic_i, 1 \leq i \leq n

It is easy to see that the given grammar generates the langauge L_{AB} . The reduction outputs the grammar thus constructed.

To see why this is a valid reduction, let there be a solution to the post correspondence problem, i.e. 11. ..., im such that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} . Then the string a_{i_1}\ldots a_{i_m}c_{i_m}\ldots c_{i_1} = b_{i_1}\ldots b_{i_m}c_{i_m}\ldots c_{i_1} has two difference derivations in the given grammar, one using S_A and the other using S_B .

Conversely, let a string generated by the given grammar have two different derivations. Note that S_A and S_B can only generate one derivation tree for any string, hence the only way for two different derivations to happen is for one of them to go to S_A and the other to S_B .

Let the string for which ambiguity appears be of the form a_{i_1}\ldots a_{i_m}c_{i_m}\ldots c_{i_1} . Then the other derivation must produce a string of the form b_{i_1}\ldots b_{i_m}c_{i_m}\ldots c_{i_1} , this is because both derivations must produce the same string for ambiguity to occur, hence the part which uses c_i must be the same. Note that this further implies that a_{i_1}\ldots a_{i_m} = b_{i_1}\ldots b_{i_m} , which is equivalent to saying that the post correspondence problem has a solution.

Hence the reduction works as expected. This proves that the ambiguous CFG problem is undecidable, otherwise post correspondence problem would be decidable, which is a contradiction.

4 0
3 years ago
USB flash drives are small portable units that are used to ____________files.
Juliette [100K]

Answer:D

Explanation: they do all of these

3 0
4 years ago
Read 2 more answers
Other questions:
  • You have just deployed SNMPv3 in your environment. Your manager asks you to make sure that your SNMP agents can only talk to the
    13·2 answers
  • What is the answer please
    13·2 answers
  • PLEASE FILL IN THE BLANK FOR THESE POINTS!!!!!
    15·2 answers
  • PLZ HURRRYYYYYY
    15·1 answer
  • Write a C# program named InchesToCentimeters that declares a named constant that holds the number of centimeters in an inch: 2.5
    14·1 answer
  • The ____ of a variable is the location in memory where it’s value is stored. A. Value B. Address C. Data type D. Number
    8·1 answer
  • Which part of the Word screen matches label A?
    13·1 answer
  • Which of the following are examples of how a company might use consumer data it had collected? a To decide what types of product
    10·1 answer
  • Apakah kebaikan mengetahui fungsi elemen pada produk mekatronik​
    5·1 answer
  • // This pseudocode segment is intended to compute the number
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!