What Is Dynamic Array In Java? | How Do They Work? - Edureka
Maybe your like
- Blog
- What Is Dynamic Array In Java?
Introduction to Java
- What Is Java? A Beginner's Guide to Java and Its Evolution
- Why Java is a Popular Programming Language?
- Top 10 Reasons Why You Should Learn Java
- Why Java is a Secure language?
- What are the different Applications of Java?
- Java for Android: Know the importance of Java in Android
- What is the basic Structure of a Java Program?
- What is the difference between C, C++ and Java?
- Java 9 Features and Improvements
- Top 10 Java Frameworks You Should Know
- Netbeans Tutorial: What is NetBeans IDE and how to get started?
Environment Setup
- How To Set Path in Java?
- How to Write Hello World Program in Java?
- How to Compile and Run your first Java Program?
- Learn How To Use Java Command Line Arguments With Examples
Control Statements
- What is for loop in java and how to implement it?
- What is a While Loop in Java and how to use it?
- What is for-each loop in Java?
- What is a Do while loop in Java and how to use it?
- What is a Switch Case In Java?
Java Core Concepts
- Java Tutorial For Beginners – Java Programming Made Easy!
- What are the components of Java Architecture?
- What are Comments in Java? – Know its Types
- What are Java Keywords and reserved words?
- What is a Constructor in Java?
- What is the use of Destructor in Java?
- Know About Parameterized Constructor In Java With Examples
- What are Operators in Java and its Types?
- What Are Methods In Java? Know Java Methods From Scratch
- What is Conditional Operator in Java and how to write it?
- What is a Constant in Java and how to declare it?
- What is JIT in Java? – Understanding Java Fundamentals
- What You Should Know About Java Virtual Machine?
- What is the role for a ClassLoader in Java?
- What is an Interpreter in Java?
- What is Bytecode in Java and how it works?
- What is a Scanner Class in Java?
- What is the Default Value of Char in Java?
- this Keyword In Java – All You Need To Know
- What is Protected in Java and How to Implement it?
- What is a Static Keyword in Java?
- What is an Array Class in Java and How to Implement it?
- What is Ternary Operator in Java and how can you use it?
- What is Modulus in Java and how does it work?
- What is the difference between Method Overloading And Overriding?
- Instance variable In Java: All you need to know
- Know All About the Various Data Types in Java
- What is Typecasting in Java and how does it work?
- How to Create a File in Java? – File Handling Concepts
- File Handling in Java – How To Work With Java Files?
- What is a Comparator Interface in Java?
- Comparable in Java: All you need to know about Comparable & Comparator interfaces
- What is Iterator in Java and How to use it?
- Java Exception Handling – A Complete Reference to Java Exceptions
- All You Need to Know About Final, Finally and Finalize in Java
- How To Implement Volatile Keyword in Java?
- Garbage Collection in Java: All you need to know
- What is Math Class in Java and How to use it?
- What is a Java Thread Pool and why is it used?
- Synchronization in Java: What, How and Why?
- Top Data Structures & Algorithms in Java That You Need to Know
- Java EnumSet: How to use EnumSet in Java?
- How to Generate Random Numbers using Random Class in Java?
- Generics in Java – A Beginners Guide to Generics Fundamentals
- What is Enumeration in Java? A Beginners Guide
- Transient in Java : What, Why & How it works?
- What is Wait and Notify in Java?
- Swing In Java : Know How To Create GUI With Examples
- Java AWT Tutorial – One Stop Solution for Beginners
- Java Applet Tutorial – Know How to Create Applets in Java
- How To Implement Static Block In Java?
- What is Power function in Java? – Know its uses
- Java Array Tutorial – Single & Multi Dimensional Arrays In Java
- Access Modifiers in Java: All you need to know
- What is Aggregation in Java and why do you need it?
- How to Convert Int to String in Java?
- What Is A Virtual Function In Java?
- Java Regex – What are Regular Expressions and How to Use it?
- What is PrintWriter in Java and how does it work?
- All You Need To Know About Wrapper Class In Java : Autoboxing And Unboxing
- How to get Date and Time in Java?
- What is Trim method in Java and How to Implement it?
- How do you exit a function in Java?
- What is AutoBoxing and unboxing in Java?
- What is Factory Method in Java and how to use it?
- Threads in Java: Know Creating Threads and Multithreading in Java
- Join method in Java: How to join threads?
- What is EJB in Java and How to Implement it?
- What is Dictionary in Java and How to Create it?
- Daemon Thread in Java: Know what are it's methods
- How To Implement Inner Class In Java?
- What is Stack Class in Java and how to use it?
Java Strings
- What is the concept of String Pool in java?
- Java String – String Functions In Java With Examples
- Substring in Java: Learn how to use substring() Method
- What are Immutable String in Java and how to use them?
- What is the difference between Mutable and Immutable In Java?
- BufferedReader in Java : How To Read Text From Input Stream
- What are the differences between String, StringBuffer and StringBuilder?
- Split Method in Java: How to Split a String in Java?
- Know How to Reverse A String In Java – A Beginners Guide
- What is Coupling in Java and its different types?
- Everything You Need to Know About Loose Coupling in Java
- What is Trim method in Java and How to Implement it?
Objects and Classes
- Packages in Java: How to Create and Use Packages in Java?
- Java Objects and Classes – Learn how to Create & Implement
- What is Object in Java and How to use it?
- Singleton Class in Java – How to Use Singleton Class?
- What are the different types of Classes in Java?
- What is a Robot Class in Java?
- What is Integer class in java and how it works?
- What is System Class in Java and how to implement it?
- What is the role for a ClassLoader in Java?
- Char in Java: What is Character class in Java?
- What is the Boolean Class in Java and how to use it?
Java OOPS
- Object Oriented Programming – Java OOPs Concepts With Examples
- Inheritance in Java – Mastering OOP Concepts
- Polymorphism in Java – How To Get Started With OOPs?
- How To Implement Multiple Inheritance In Java?
- Java Abstraction- Mastering OOP with Abstraction in Java
- Encapsulation in Java – How to master OOPs with Encapsulation?
- How to Implement Nested Class in Java?
- What is the Use of Abstract Method in Java?
- What is Association in Java and why do you need it?
- What is the difference between Abstract Class and Interface in Java?
- What is Runnable Interface in Java and how to implement it?
- What is Cloning in Java and its Types?
- What is Semaphore in Java and its use?
- What is Dynamic Binding In Java And How To Use It?
Java Collections
- Java Collections – Interface, List, Queue, Sets in Java With Examples
- List in Java: One Stop Solution for Beginners
- Java ArrayList: A Complete Guide for Beginners
- Linked List in Java: How to Implement a Linked List in Java?
- What are Vector in Java and how do we use it?
- What is BlockingQueue in Java and how to implement it?
- How To Implement Priority Queue In Java?
- What is Deque in Java and how to implement its interface?
- What are the Legacy Classes in Java?
- Java HashMap – Know How to Implement HashMap in Java
- What is LinkedHashSet in Java? Understand with examples
- How to Implement Map Interface in Java?
- Trees in Java: How to Implement a Binary Tree?
- What is the Difference Between Extends and Implements in Java?
- How to Implement Shallow Copy and Deep Copy in Java
- How to Iterate Maps in Java?
- What is an append Method in Java?
- How To Implement Treeset In Java?
- Java HashMap vs Hashtable: What is the difference?
- How to Implement Method Hiding in Java
- How To Best Implement Concurrent Hash Map in Java?
- How To Implement Marker Interface In Java?
Java Programs
- Palindrome in Java: How to check a number is palindrome?
- How to check if a given number is an Armstrong number or not?
- How to Find the largest number in an Array in Java?
- How to find the Sum of Digits in Java?
- How To Convert String To Date In Java?
- Ways For Swapping Two Numbers In Java
- How To Implement Addition Of Two Numbers In Java?
- How to implement Java program to check Leap Year?
- How to Calculate Square and Square Root in Java?
- How to implement Bubble Sort in Java?
- How to implement Perfect Number in Java?
- What is Binary Search in Java? How to Implement it?
- How to Perform Merge Sort in Java?
- Top 30 Pattern Program in Java: How to Print Star, Number and Character
- Know all about the Prime Number program in Java
- How To Display Fibonacci Series In Java?
- How to Sort Array, ArrayList, String, List, Map and Set in Java?
- How To Create Library Management System Project in Java?
- How To Practice String Concatenation In Java?
- How To Convert Binary To Decimal In Java?
- How To Convert Double To Int in Java?
- How to convert Char to Int in Java?
- How To Convert Char To String In Java?
- How to Create JFrame in Java?
- What is Externalization in Java and when to use it?
- How to read and parse XML file in Java?
- How To Implement Matrix Multiplication In Java?
- How To Deal With Random Number and String Generator in Java?
- Basic Java Programs for Practice With Examples
Advance Java
- How To Connect To A Database in Java? – JDBC Tutorial
- Advanced Java Tutorial- A Complete Guide for Advanced Java
- Servlet and JSP Tutorial- How to Build Web Applications in Java?
- Introduction to Java Servlets – Servlets in a Nutshell
- What Is JSP In Java? Know All About Java Web Applications
- How to Implement MVC Architecture in Java?
- What is JavaBeans? Introduction to JavaBeans Concepts
- Know what are the types of Java Web Services?
- JavaFX Tutorial: How to create an application?
- What is Executor Framework in Java and how to use it?
- What is Remote Method Invocation in Java?
- Everything You Need To Know About Session In Java?
- Java Networking: What is Networking in Java?
- What is logger in Java and why do you use it?
- How To Handle Deadlock In Java?
- Know all about Socket Programming in Java
- Important Java Design Patterns You Need to Know About
- What is ExecutorService in Java and how to create it?
- Struts 2 Tutorial – One Stop Solution for Beginners
- What is Hibernate in Java and Why do we need it?
- What is Maven in Java and how do you use it?
- What is Machine Learning in Java and how to implement it?
Career Opportunities
- Java Developer Resume: How to Build an Impressive Resume?
- What is the Average Java Developer Salary?
Interview Questions
- Java Interview Questions and Answers
- Top MVC Interview Questions and Answers for 2025
- Top 50 Java Collections Interview Questions You Need to Know in 2025
- Top 50 JSP Interview Questions You Need to Know in 2025
- Top 50 Hibernate Interview Questions That Are A Must in 2025
Programming & Frameworks
Topics Covered- C Programming and Data Structures (16 Blogs)
- Comprehensive Java Course (5 Blogs)
- Java/J2EE and SOA (341 Blogs)
- Spring Framework (9 Blogs)
- Bookmark





Copy Link! Become a Certified ProfessionalArrays in Java are homogeneous data structures implemented in Java as objects. Arrays store one or more values of a specific data type and provide indexed access to store the same. A specific element in an array is accessed by its index. In this article, we will discuss Dynamic Array in Java in the following sequence:
Table of Content- Introduction to Dynamic Array in Java
- Size vs. Capacity
- Doubling Appends
- Deleting an Element
- Resizing an Array
- Introduction to Dynamic Array in Java
- Size vs Capacity
- Doubling Appends
- Deleting an Element
- Resizing a Dynamic Array in Java
Introduction to Dynamic Array in Java
The dynamic array is such a type of an array with a huge improvement for automatic resizing. The only limitation of arrays is that it is a fixed size. This translates into a meaning that you can only specify the number of elements that your array can hold ahead of time. On the other hand, the dynamic arrays can expand as we add more elements in real-time. Therefore, the coder does not need to determine the size of the array ahead of time. It does have a few more strengths as well:
Quick lookup. Same as just like arrays, when retrieving the element at a given index, takes O (1) time.
Variable size. We can insert as many elements as we want and a dynamic array will accordingly expand to hold them.
Cache-friendly. Similar to arrays, dynamic arrays can put items next to each other in memory, thus making efficient utilization of caches.
There are some downsides to using dynamic arrays in our code. Although, we do use dynamic arrays more than anything does in most applications there are some cases where they do not become the most preferred choice due to its limitations.
Slow worst-case appends. Normally, while the addition of a new element at the end of a dynamic array, it takes O (1) at one instance. However, if the dynamic array does not have any more indices for a new item, then it will need to expand, which takes O (n) at a time.
Costly inserts and deletes. Similar to arrays, the elements are stored adjacent to each other. So while adding or removing an item in the center of an array it requires pushing other elements, which takes O (n) at a time.
The below diagrams show how the arrays work in real-time and depict how the elements are stacked up. It also shows how the instructions change for an average case and the worst case of array functions.


Size vs. Capacity
When we initialize a dynamic array, the dynamic array implementation creates an understood fixed-size array. The initial size corresponds to the implementation. For example, let us make our implementation array to use 10 indices. Now we append four items to our dynamic array. Now, our dynamic array has a length of four. However, our underlying array has a length of 10. Hence, we could say that dynamic array size is four and its capacity is 10. A dynamic array stores a specific end Index to keep track of the ending point of the dynamic array and the starting point from where the extra capacity begins.


Doubling Appends
There can be cases where we try to append an item to an array where the capacity is already full. Hence, to create room dynamic arrays automatically create new, bigger and underlying array. Usually, it becomes twice as big to handle any new additions, which it did not anticipate earlier. Hence, copying each item consumes no time. Whenever appending an item to our dynamic array automatically makes a new double-size underlying array, which append takes no time.
Deleting an Element
While deleting an element from an array, the default “remove()” method removes an element from the end and automatically stores zero at the last index. It will also delete elements at a specific index by calling removeAt(i) method where “I” is index. The removeAt(i) method shifts all the right elements in the left side from the given index.

Resizing an Array
When arrays have no data at the right side of the array which than take unnecessary memory, the method srinkSize() frees extra memory. When all slots are consumed and additional elements are added, the underlying fixed-size array has to increase size. The actual resizing is expensive, as we have to allocate a bigger array and copy forward all elements from an array you have overgrown before it can finally append a new item.

Below is an example of a program where the array size becomes full and new elements are copied to a new double size array. The element which is a string element called “Mahavir” is an addition to the already full array of size 3.
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class AddingItemsDynamically { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter the size of the array :: "); int size = sc.nextInt(); String myArray[] = new String[size]; System.out.println("Enter elements of the array (Strings) :: "); for(int i=0; i<size; i++) { myArray[i] = sc.next(); } System.out.println(Arrays.toString(myArray)); ArrayList<String> myList = new ArrayList<String>(Arrays.asList(myArray)); System.out.println("Enter the element that is to be added:"); String element = sc.next(); myList.add(element); myArray = myList.toArray(myArray); System.out.println(Arrays.toString(myArray)); } }Output:

With this, we come to the end of Dynamic Array in Java article. I hope you got an idea of how to work with dynamic arrays.
Check out theJava Online Course by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. Edureka’s Java J2EE and SOA training and certification course is designed for students and professionals who want to be a Java Developer. The course is designed to give you a head start into Java programming and train you for both core and advanced Java concepts along with various Java frameworks like Hibernate & Spring.
Got a question for us? Please mention it in the comments section of this “Dynamic Array in Java” blog and we will get back to you as soon as possible.
Recommended videos for you

Hibernate-the ultimate ORM framework
Watch Now
Create Restful Web Application With Node.js Express
Watch Now
Spring Framework : Introduction to Spring Web MVC & Spring with BigData
Watch Now
Node JS : Steps to Create Restful Web App
Watch Now
Learn Perl-the Jewel of Scripting Languages
Watch Now
PHP & MySQL : Server-side Scripting Language for Web Development
Watch Now
MS .Net – An IntelliSense Way of Web Development
Watch Now
Introduction to JAVA/J2EE & SOA
Watch Now
Microsoft SharePoint 2013 : The Ultimate Enterprise Collaboration Platform
Watch Now
Rapid Development With CakePHP
Watch Now
Implementing Web Services In Java
Watch Now
Microsoft Sharepoint 2013 : The Ultimate Enterprise Collaboration Platform
Watch Now
PHP and MySQL : Server Side Scripting For Web Development
Watch Now
Effective Persistence Using ORM With Hibernate
Watch Now
A Day In The Life Of A Node.js Developer
Watch Now
Responsive WEB APP using cakePHP
Watch Now
Microsoft SharePoint-The Ultimate Enterprise Collaboration Platform
Watch Now
Portal Development and Text Searching with Hibernate
Watch Now
Node JS Express: Steps to Create Restful Web App
Watch Now
Mastering Regex in Perl
Watch NowRecommended blogs for you

Learn How to Declare String in Java with Examples
Read Article
Your Guide To Java Career Opportunities: How To Bag Top Java Jobs
Read Article
Java Networking: What is Networking in Java?
Read Article
Servlet and JSP Tutorial- How to Build Web Applications in Java?
Read Article
How to Read and Write Excel file in Java
Read Article
What is bootstrap list and how to use bootstrap list group?
Read Article
What is Machine Learning in Java and how to implement it?
Read Article
Daemon Thread in Java: Know what are it’s methods
Read Article
How to Implement Command Line Arguments in Java
Read Article
What Is Header Location In PHP?
Read Article
How to Write RESTful Web Services With JAX-WS
Read Article
Sets In Java: Know how to work with Java Set Interface
Read Article
Introduction to Java Servlets – Servlets in a Nutshell
Read Article
Why Java is a Popular Programming Language?
Read Article
Top 10 popular Java IDE: Choose the Best IDE for Java
Read Article
Top 60+ Spring Boot Interview Questions That Are A Must in 2025
Read Article
List in Java: One Stop Solution for Beginners
Read Article
Access Modifiers in Java: All you need to know
Read Article
Top Data Structures & Algorithms in Java That You Need to Know
Read Article
Everything you need to know about Variables in Java
Read Article Comments 0 CommentsJoin the discussionCancel reply
Trending Courses in Programming & Frameworks

Java Course Online
- 82k Enrolled Learners
- Weekend/Weekday
- Live Class

Full Stack Development Internship Program
- 29k Enrolled Learners
- Weekend/Weekday
- Live Class

Python Scripting Certification Training
- 15k Enrolled Learners
- Weekend
- Self Paced

Flutter App Development Certification Course
- 13k Enrolled Learners
- Weekend/Weekday
- Live Class

Node JS Course with Certification
- 11k Enrolled Learners
- Weekend/Weekday
- Live Class

Spring Framework Certification Course
- 13k Enrolled Learners
- Weekend/Weekday
- Live Class

Data Structures and Algorithms using Java Int ...
- 31k Enrolled Learners
- Weekend/Weekday
- Live Class

Comprehensive Java Course Certification Train ...
- 19k Enrolled Learners
- Weekend/Weekday
- Self Paced

Advanced Java Certification Training
- 7k Enrolled Learners
- Weekend/Weekday
- Self Paced

Microsoft .NET Framework Certification Traini ...
- 6k Enrolled Learners
- Weekend/Weekday
- Self Paced
Browse Categories
Artificial IntelligenceAWSBI and VisualizationBig DataBlockchainBusiness ManagementCloud ComputingCyber SecurityData ScienceData Warehousing and ETLDatabasesDevOpsDigital MarketingEnterpriseFront End Web DevelopmentHuman Resource ManagementInterview QuestionsMobile DevelopmentOperating SystemsOperations ManagementProduct ManagementProject Management and MethodologiesRobotic Process Automationseo interview questionSoftware TestingStrategy and LeadershipSupply Chain ManagementSystems & ArchitectureSubscribe to our Newsletter, and get personalized recommendations.
Already have an account? Sign in.
20,00,000 learners love us! Get personalised resources in your inbox.
Sign up with Gmail Sign up with FacebookOR
Password must haveAt least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
SIGN UP Already have an Edureka Account? Login Forgot Password? LOGIN Don’t have edureka account? Sign Up resend ? Password must haveAt least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
reset password Don’t have edureka account? Sign Up reset password Don’t have edureka account? Sign Up Send Code Don’t have edureka account? Sign UpAwesome
We have recieved your contact details.
You will recieve an email from us shortly.
What is Dynamic Array in Java?
edureka.co
Tag » Add Element Dynamic Array Java
-
How To Add Items To An Array In Java Dynamically? - Tutorialspoint
-
Dynamic Array In Java - Javatpoint
-
How Can I Dynamically Add Items To A Java Array? - Stack Overflow
-
Creating A Dynamic Array In Java - GeeksforGeeks
-
How To Add And Remove Elements From An Dynamic Array In Java ...
-
How To Add Elements To An Array In Java Dynamically Code Example
-
How Does Dynamic Array Work In Java? - EduCBA
-
Create A Dynamic Array In Java | Delft Stack
-
Add New Elements To An Array In Java - Techie Delight
-
Adding An Element To A Java Array Vs An ArrayList - Baeldung
-
Dynamic Array Data Structure - Interview Cake
-
How To Add Elements To An Array In Java - Software Testing Help
-
Java Dynamic Arrays - DevTown
-
Create A Dynamic Array And Find The Largest Number Of The Array
-
Amortized Analysis Of Dynamic Arrays
-
Dynamic Array Java Example
-
How Do Dynamic Array Work? - Java Development Journal
-
How To Add Elements To An Array In Java Dynamically - MaxInterview
-
[PDF] Dynamic Array