How to use arraylist in java netbeans?



How to use arraylist in java netbeans?..

Answer / Bhupendra Kumar Singh

To use ArrayList in NetBeans, you first need to import it. You can do this by adding the following line at the top of your Java file:

```java
import java.util.*;

After that, you can create an ArrayList object and add elements as shown below:

ArrayList<String> list = new ArrayList<String>();
list.add("Element1");
list.add("Element2");
...
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is meant by method?

1 Answers  


Is 0 true or is 1 true?

1 Answers  


When does the compiler supply a default constructor for a class?

9 Answers   TCS,


Is char * a string?

1 Answers  


Objects or references which of them gets garbage collected?

1 Answers  


In how many ways we can do exception handling in java?

1 Answers  


What is use of set in java?

1 Answers  


What is protected and friendly?

1 Answers  


What is the benefit of inner classes in java?

1 Answers  


Can inner class have constructor?

1 Answers  


What is the argument type of main() method?

2 Answers  


How are variables stored?

1 Answers  


Categories