class A implements Cloneable
{
int age;
A(int age)
{
this.age=age;
}
public int getage()
{
return age;
}
public Object clone()
{
A aa=null;
try
{
aa=(A)super.clone();
}
catch(Exception e)
{
}
finally
{
return aa;
}
}
public static void main(String str[])
{
A a1=new A(10);
A a2=(A)a1.clone();
System.out.println(a1.getage()+"==="+a2.getage());
System.out.println(a1.equals(a2));
}
}
import java.util.*;
class Demo
{
public static void main( String args[] )
{
PriorityQueue<Integer> p=new PriorityQueue<Integer>();
p.offer(1);
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());
for(int i : p)
{
System.out.println("poll");
p.poll();
System.out.println("size:"+p.size());
}
System.out.println("added two elements");
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());
for(int i : p)
{
System.out.println("peek");
p.peek();
System.out.println("size:"+p.size());
}
}
}
import java.util.*;
class Demo
{
public static void main( String args[] )
{
PriorityQueue<Integer> p=new PriorityQueue<Integer>();
p.offer(1);
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());
for(int i)
{
System.out.println("poll");
p.poll();
System.out.println("size:"+p.size());
}
System.out.println("added two elements");
p.offer(1);
p.offer(1);
System.out.println("size:"+p.size());
for(int i)
{
System.out.println("peek");
p.peek();
System.out.println("size:"+p.size());
}
}
}
Hi i have doubt in matching exactly the STATEMENTS and their COLLECTION TYPES.
Given the Statements :
1. Allows access to elements by their integer index
2. defines the method: Vgey(Object Key)
3. is designed for hacking elements prior to processing.
4. Contains no pair of elements e1 and e2 such that e1.equals(e2).
Collection Types :
1.Java.util.Map
2.Java.util.Set
3.Java.util.List
4.Java.util.Ques