According to the explanation as I understand it, option#3 is correct but yet it is not. Please explain.
Except:
size() method of ArrayList returns the number of elements. Here, it returns 2. Since numbering in ArrayList starts with 0. al.get(2) will cause an IndexOutOfBoundsException to be thrown because only 0 and 1 are valid indexes for a list of size 2.
About Question enthuware.ocajp.i.v7.2.870 :
Moderator: admin
-
- Posts: 36
- Joined: Tue May 06, 2014 8:30 am
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.870 :
It seems to be because of the same repaint problem that you reported earlier. Please see attached image.
- Attachments
-
- 2.870.png (23.48 KiB) Viewed 2476 times
If you like our products and services, please help us by posting your review here.
-
- Posts: 28
- Joined: Mon Sep 25, 2017 8:16 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.870 :
Code: Select all
ArrayList<String> al = new ArrayList<String>();
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.870 :
Yes, it can be.JuergGogo wrote:This ArrayList can be declared also like: ArrayList<String> al = new ArrayList<>();Code: Select all
ArrayList<String> al = new ArrayList<String>();
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 41 guests