Arraylist

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
RRRRRR
Posts: 26
Joined: Sun Jul 23, 2017 2:13 am
Contact:

Arraylist

Post by RRRRRR »

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??

admin
Site Admin
Posts: 10061
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Arraylist

Post by admin »

If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], gadsgadsx and 107 guests