Java - Array List and Array Class in Collection and Collections (Example and Methods)
package collection_examples;
import java.util.*;
public class ArrayListExample {
public static void main(String[] args) {
ArrayList array1=new ArrayList();
array1.add("Apple");
array1.add("Ball");
array1.add("Cat");
ArrayList array=new ArrayList();
array.add("Ravi");
array.add("Kumar");
array.add("Sagar");
//array.remove("Ravi");
array.add(2,"ravi");
//array.removeAll(array);
array.addAll(array1);
//System.out.print(array);
Iterator it=array.iterator();
while (it.hasNext()){
System.out.println(it.next());
}
}
}
package collection_examples;
import java.util.*;
public class ArrayListExample {
public static void main(String[] args) {
ArrayList array1=new ArrayList();
array1.add("Apple");
array1.add("Ball");
array1.add("Cat");
ArrayList array=new ArrayList();
array.add("Ravi");
array.add("Kumar");
array.add("Sagar");
//array.remove("Ravi");
array.add(2,"ravi");
//array.removeAll(array);
array.addAll(array1);
//System.out.print(array);
Iterator it=array.iterator();
while (it.hasNext()){
System.out.println(it.next());
}
}
}
Sorting and Searching Programs
Start with your Choice
-Important
Programs for Freshers
- Palindrome Number
- Prime
Number
- Swapping
Number
- Leap
Year
- Odd
and Even Number
- Fibonacci
Series
- Armstrong
Number
- Factorial
Number
- Print
Table
Learn Pattern Programs
- Alphabet
pattern program in java
- Star Pattern Programs in Java
- Square
pattern programs in java
- Diamond
Star pattern programs in java
- Number
Pattern Programs in java
- Diagonal
pattern program in java
- 4
ways to print Array in Java
- 2D
Array in Java
- Anonymous
Array in Java
- Single
Dimensional Array in Java
- Find
Second Largest Number in Array
- Delete
an Element in Array in Java
- Common
Element in Array in Java
- Missing
Element in Array
- Insert
Element in Array
- Reverse Array in Java
- Merge Two Array in Java
- Smallest
and Largest Elements in Array
- Find
Odd and Even Number in Array
Click to Learn
MySQL
Learn
with us | HTML | CSS | JS | Bootstrap | JAVA | ADV JAVA | MySQL | GIT
No comments:
Post a Comment