The Java ArrayList add() method allows you to add elements to an ArrayList. You can use it to add elements at the end of the list or at a specific position.
Adding an element without specifying an index appends it to the end.
Adding an element with an index places it at the specified position, shifting existing elements.
For example:
If you have a list and add “Apple” and “Banana,” they will appear at the end of the list. If you then insert “Orange” at index 1, it will appear between “Apple” and “Banana.”