Question

In: Computer Science

In your own words, explain what is meant by an Array and ArrayList. Give two examples...

In your own words, explain what is meant by an Array and ArrayList. Give two examples that illustrate the main difference

Note:Java programming language

Solutions

Expert Solution

Array is a fixed length information structure though ArrayList is a variable length Collection class.We can't change length of array once made in Java yet ArrayList can be changed.

We can't store natives in ArrayList, it can just store objects.However, array can contain the two natives and items in Java.Since Java 5, natives are consequently changed over in objects which is known as auto-boxing.

Example

    import java.util.*;  
    public class ListEx {  
    public static void main(String[] args) {  
        List<Integer> list=new ArrayList<>();  
        list.add(Integer.valueOf(10));//store the Integer object  
        list.add(20);//compiler now converts it into an Integer.valueOf(20) which is an object  
        list.add(30);  
          
        System.out.println("Going through the List...");  
        for(Integer i:list){  
            System.out.println(i);  
        }  
    }  
    }  

The output will be:

Going through the List...
10
20
30

Related Solutions

a. In your own words, explain what is meant by good programming practice. Give two examples,...
a. In your own words, explain what is meant by good programming practice. Give two examples, one with good programming practice and one without good programming practice Note:java Programming Language
In your own words, explain what is meant by ‘corporate social responsibility’. Provide two examples.
In your own words, explain what is meant by ‘corporate social responsibility’. Provide two examples.
What causes trigeminal neuralgia? Explain in your own words and give examples.
What causes trigeminal neuralgia? Explain in your own words and give examples.
In your own words, describe what is meant by “fault tolerance” in a network, and give...
In your own words, describe what is meant by “fault tolerance” in a network, and give an example of how it could be implemented in a small office LAN with 25 workstations and two servers, including Internet access for the workstations, but not the internal servers.
Explain the following in your own words (be specific): What is meant by a 95% confidence...
Explain the following in your own words (be specific): What is meant by a 95% confidence interval? What is meant by the true mean and how does it relate to the confidence interval? Explain Standard Error or Margin of error and how it helps define the confidence interval?
. Explain in your own words what is meant by the term ‘price elasticity of demand’....
. Explain in your own words what is meant by the term ‘price elasticity of demand’. 2. Why is it important for business managers to understand price elasticity of demand? 3. When price elasticity of demand is greater than 1, we say that the good is: INELASTIC / ELASTIC / UNITARY ELASTIC / POSITIVELY ELASTIC 4. When price elasticity of demand is less than 1, we say that a good is: INELASTIC / ELASTIC / UNITARY ELASTIC / NEGATIVELY ELASTIC...
With respect to Ohm's Law, explain in your own words what is meant when it is...
With respect to Ohm's Law, explain in your own words what is meant when it is said that there is "a linear response between voltage and current." Name a specific device in which Ohm's Law is a good description of the relationship between current and voltage, and one for which it is not. Do your best to explain this failure in terms of the basic properties of electrons flowing through a conducting material. Describe the temperature response of resistors in...
( please in your own words) Explain what is meant by quality management and why is...
( please in your own words) Explain what is meant by quality management and why is it important?
In your own words, explain magnetic fields, forces, and give examples in daily life. In your...
In your own words, explain magnetic fields, forces, and give examples in daily life. In your own words, explain the workings of direct current motors. In your own words, explain current loops and solenoids.
Define an Accrued expense in your own words and give TWO examples OR journal entries of...
Define an Accrued expense in your own words and give TWO examples OR journal entries of an Accrued expense.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT