Arraylist
Posted: Sun Aug 06, 2017 2:26 am
Sir see->
public static void main(String[] args)
{
List<String>c=new ArrayList<String>();
c.add("123");
System.out.println(c);
System.out.println(c.get(1)); //Gives IndexOutOfBoundsException.
System.out.println(c.get(-1)); //Gives ArrayIndexOutOfBoundsException.
}
If going to negative index giving AIOOBoundsException but if going to Positive index then giving IndexOutOfBoundsException. Why??
public static void main(String[] args)
{
List<String>c=new ArrayList<String>();
c.add("123");
System.out.println(c);
System.out.println(c.get(1)); //Gives IndexOutOfBoundsException.
System.out.println(c.get(-1)); //Gives ArrayIndexOutOfBoundsException.
}
If going to negative index giving AIOOBoundsException but if going to Positive index then giving IndexOutOfBoundsException. Why??