Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Initial size of al: 0
size of al after additions 7
contents of al: [C, A2, A, E, B, D, F]
size of after deletions : 5
contents of al:[C, A2, E, B, D] [1, 2, 3, 4]

May you explain about this output:
[1, 2, 3, 4]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl hossein wrote:...
May you explain about this output:
[1, 2, 3, 4]

I have no idea. That does not appear when I run your code.
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
marc weber wrote:
abalfazl hossein wrote:...
May you explain about this output:
[1, 2, 3, 4]

I have no idea. That does not appear when I run your code.


Yup, It doesn't appear to me either...
 
prem pillai
Ranch Hand
Posts: 87
Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abalfazl , have you posted the same code which you are running?
Looks like there was a System.out.print statement after line 33 which prints another list.
You might have removed that statement and then directly ran it (but forgot to compile the modified code before running it).

Also,


You can use a single statement instead of the above two statements.

println() adds a line separator et the end of the output automatically.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic