0% found this document useful (0 votes)
5 views2 pages

Java Programs

The document contains three Java programs demonstrating various collection and string manipulation methods. The first program showcases operations on ArrayLists, TreeSets, Queues, Deques, and HashMaps. The second program focuses on string methods, including length, character access, and case conversion, while the third program illustrates StringBuffer methods such as append, insert, and delete.

Uploaded by

money2005qw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Java Programs

The document contains three Java programs demonstrating various collection and string manipulation methods. The first program showcases operations on ArrayLists, TreeSets, Queues, Deques, and HashMaps. The second program focuses on string methods, including length, character access, and case conversion, while the third program illustrates StringBuffer methods such as append, insert, and delete.

Uploaded by

money2005qw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Collection Full Methods Program


import [Link].*;

public class FullMethodsDemo {


public static void main(String[] args) {
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();

[Link](10); [Link](20); [Link](30);


[Link](20); [Link](40);

[Link](list2);
[Link]([Link](20));
[Link](list2);

[Link](50); [Link](60);
[Link]([Link](50));

[Link]([Link](50));
[Link]([Link]());

Iterator<Integer> it = [Link]();
while([Link]()) [Link]([Link]()+" ");

TreeSet<Integer> set = new TreeSet<>();


[Link](10); [Link](20); [Link](30);

[Link]([Link](30));
[Link]([Link](20));
[Link]([Link](30));

Queue<Integer> q = new PriorityQueue<>();


[Link](10); [Link](20);
[Link]([Link]());

Deque<Integer> dq = new ArrayDeque<>();


[Link](10); [Link](20);

HashMap<String,Integer> map = new HashMap<>();


[Link]("A",100);
[Link]([Link]("A"));
}
}

2. String Methods Program


class StringDemo {
public static void main(String[] args) {
String s = "Hello World";
String s1 = "Hello";
String s2 = "hello";

[Link]([Link]());
[Link]([Link](1));

char ch[] = new char[5];


[Link](0,5,ch,0);
[Link](new String(ch));

[Link]([Link]([Link]()));

[Link]([Link](s2));
[Link]([Link](s2));

[Link]([Link]("o"));
[Link]([Link](6));
[Link]([Link]('o','x'));

[Link]([Link]());
[Link]([Link]());
}
}

3. StringBuffer Methods Program


public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("Hello");

[Link]([Link]());
[Link]([Link]());

[Link](" World");
[Link](5," Java");
[Link]();

sb = new StringBuffer("Hello World");


[Link](5,11);
[Link](0,5,"Hi");

[Link]([Link](0,2));
}
}

You might also like