Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Associate Certification (OCAJP 8)
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
Jeanne Boyarsky
Paul Clapham
Sheriffs:
Liutauras Vilda
Henry Wong
Devaka Cooray
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Al Hobbs
Carey Brown
Bartenders:
Piet Souris
Mikalai Zaikin
Himai Minh
Forum:
Associate Certification (OCAJP 8)
Why does the below program print [B, A]?
Clemonte Johnstone
Ranch Hand
Posts: 125
2
posted 1 year ago
Number of slices to send:
Optional 'thank-you' note:
Send
Why does the below program print [B, A]? Shouldn't index 0 be overwritten?
List<String> list = new ArrayList<>(); list.add(0, "A"); list.add(0, "B"); System.out.println(list);
Dave Tolls
Rancher
Posts: 4801
50
posted 1 year ago
Number of slices to send:
Optional 'thank-you' note:
Send
Try the API docs for the
add method
.
"Shifts the element currently at that position (if any) and any subsequent elements to the right"
Mike Simmons
Rancher
Posts: 4249
57
posted 1 year ago
Number of slices to send:
Optional 'thank-you' note:
Send
You can also compare this to the
set method
.
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
I am getting "void type not allowed here" error
OCP || Working of ListIterator methods - hasPrevious() and previous()
sum of non numeric elements in an ArrayList
Java generics/ArrayList question.
My Preparation snippets (Collections!)
More...