Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Difference between Arrays and Collection in Java
Next article icon

Difference between Arrays and Collection in Java

Last Updated : 29 Mar, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

An array in Java is a group of like-typed variables referred to by a common name. Arrays in Java work differently than they do in C/C++. Following are some important points about Java arrays. On the other hand, any group of individual objects which are represented as a single unit is known as the collection of the objects. In Java, a separate framework named the “Collection Framework” has been defined in JDK 1.2 which holds all the collection classes and interface in it.

The most essential thing while dealing Collection is to have super strong grasp of Collection framework which in one go is depicted via below image as follows:

Example

Java
// Java Program to Illustrate Difference // Between Arrays and Collection  // Importing required classes import java.util.*;  // Main class class GFG {      // Main driver method     public static void main(String[] args)     {          // Arrays         String[] gfg             = new String[] { "G", "E", "E", "K", "S" };          // Trying printing the above array         System.out.print(gfg);          // New Line         System.out.println();          // Collection         // Let us arbitarly create an empty ArrayList         // of string type         ArrayList<String> al = new ArrayList<String>();          // Adding elements to above List         // using add() method         al.add("g");         al.add("e");         al.add("e");         al.add("k");         al.add("s");          // Printing all elements of Collection (ArrayList)         System.out.println(al);     } } 

Output
[Ljava.lang.String;@3d075dc0 [g, e, e, k, s]

Now after having understanding of Arrays and Collection, let us now tabulate differences between them which is as follows:

 ArraysCollection
1Arrays are fixed in size that is once we create an array we can not increased or decreased based on our requirement.Collection are growable in nature that is based on our requirement. We can increase or decrease of size.
2Write in memory Arrays are not recommended to use.Write in  memory collection are recommended to use.
3With respect to performance Arrays are recommended to use.With respect to performance collection are not recommended to use.
4Arrays can hold only homogeneous data types elements.Collection can hold both homogeneous and heterogeneous elements.
5There is no underlying data structure for arrays and hence ready made  method support is not available.Every collection class is implemented based on some standard data structure, and hence, ready-made method support is available for every requirement. As performance is crucial, we can use these methods directly, and we are not responsible for implementing them.
6Arrays can hold both object and primitive data type .Collection can hold only object types but not primitive datatypes such as int, long, short, etc. 

Next Article
Difference between Arrays and Collection in Java

K

keep_silent
Improve
Article Tags :
  • Java
Practice Tags :
  • Java

Similar Reads

    Difference Between Streams and Collections in Java
    Collection is an in-memory data structure, which holds all the values that the data structure currently has. Every element in the Collection has to be computed before we add it to the Collection. Operations such as searching, sorting, insertion, manipulation, and deletion can be performed on a Colle
    3 min read
    Difference between List and ArrayList in Java
    A Collection is a group of individual objects represented as a single unit. Java provides a Collection Framework which defines several classes and interfaces to represent a group of objects as a single unit This framework consists of the List Interface as well as the ArrayList class. In this article
    4 min read
    Difference between Array and String in Java
    An array is a collection of similar type of elements that are stored in a contiguous memory location. Arrays can contain primitives(int, char, etc) as well as object(non-primitives) references of a class depending upon the definition of the array. In the case of primitive data type, the actual value
    5 min read
    Difference between ArrayList and HashSet in Java
    Here are couple of differences between ArrayList and HashSet. Inheritance: Implementation: Implementation : ArrayList implements List interface while HashSet implements Set interface in Java.Internal implementation: ArrayList is backed by an Array while HashSet is backed by an HashMap.Duplicates : A
    3 min read
    Difference Between List and Set in Java
    The List interface allows storing the ordered collection. It is a child interface of Collection. It is an ordered collection of objects in which duplicate values are allowed to store. List preserves the insertion order, it allows positional access and insertion of elements. Declaration: public abstr
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences