Skip to main content

ARRAY vs ARRAYLIST


ARRAY vs ARRAYLIST
Array is an object used to save similar data type elements and its size is limited.
Array is static in nature. Once created we cannot change size of array.
  • ·       Random access, linear data structure
  • ·       Fixed size once created
  • ·       Can contain objects and primitives
  • ·       Must declare element type
  • ·       It is not a class
  • ·       Elements accessible with index number
Eg: int[] ar=new int[3]; //stores complete integer types

Arraylist is a part of Collection Framework of util package to store different data type objects and it is growable. Arraylist is dynamic in nature. It can be re-size itself when needed depending upon capacity and load factor.
  • ·       Random access, linear data structure
  • ·       Dynamic size, grows automatically
  • ·       Can only contain objects
  • ·       Element type  is OBJECT
  • ·       It is a class with many methods
  • ·       Accessing methods like get() etc are available
Eg: Arraylist arr=new Arraylist();
       arr.add(13); //integer type
       arr.add(13); //string type

ArrayList<String> stringList = new ArrayList<String>(); //Generic ArrayList to Store only String objects

The Methods Of ArrayList class are:
1)Add - stringList.add(“item”);
2)Remove- stringList.remove(0);
3)Clear- stingList.clear();
4)Insert
5)TrimToSize
6)Sort
7)Reverse 

Example:
import java.util.ArrayList;
public class Program
{
          public static void main(String[] args)
          {
// Create new ArrayList.
                              ArrayList<Integer> elements = new ArrayList<>();
// Add three elements.
                              elements.add(10);
                              elements.add(15);
                              elements.add(20);
// Get size and display.
                              int count = elements.size();
                              System.out.println("Count: " + count);
// Loop through elements.
                              for (int i = 0; i < elements.size(); i++)
{
                                          int value = elements.get(i);
                                          System.out.println("Element: " + value);
                              }
          }
}

Output
Count: 3
Element: 10
Element: 15
Element: 20

Comments

Popular posts from this blog

Advantages and Disadvantages of EIS Advantages of EIS Easy for upper-level executives to use, extensive computer experience is not required in operations Provides timely delivery of company summary information Information that is provided is better understood Filters data for management Improves to tracking information Offers efficiency to decision makers Disadvantages of EIS System dependent Limited functionality, by design Information overload for some managers Benefits hard to quantify High implementation costs System may become slow, large, and hard to manage Need good internal processes for data management May lead to less reliable and less secure data

CONCEPTUAL VIEW OF MIS

The concept is a blend of principles, theories and practices of management, information and system giving rise to a single product called MANAGEMENT INFORMATION SYSTEM . The concept of management gives high regard to the individual and his ability to use the information. MIS gives information through data analysis. While analyzing the information, it relies on many academic disciplines like management science, OR, organization behavior, psychology, etc. The foundation of MIS is the principles of management and its practices. MIS uses the concept of management control in its design and relies heavily on the fact that the decision maker is a human being and is a human processor of information. A MIS can be evolved for a specific objective it is evolved after systematic planning and design. It calls for an analysis of business, management views and policies, organization culture and the management style. The MIS,therefore relies heavily on systems theory.The systems theory offers soluti

Inter-Organizational Value Chain

The value chain of   a company is part of over all value chain. The over all competitive advantage of an organization is not just dependent on the quality and efficiency of the company and quality of products but also upon the that of its suppliers and wholesalers and retailers it may use. The analysis of overall supply chain is called the value system. Different parts of the value chain 1.  Supplier     2.  Firm       3.   Channel 4 .   Buyer