• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not sure why I am getting an error on the line: lst.remove(2);  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the example program:

The line al.remove(3);   
does not give an error.
But on my program, the line where I stopped: lst,remove(2);
gives an error that says : Change to 'length'

Please help.
 
Martin Ndhlovu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I forgot to post the code.
Here it is:

 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrays don't have remove method.

What is the problem with the code from 1st post?
 
Martin Ndhlovu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the first post line 26 has the code:   al.remove(3);   and it does not give an error.
That program funs fine.
But on my program, the line lst.remove(2); gives an error.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the first program you use an ArrayList which has remove method.
In the second program you use a String[] which doesn't have remove method.
 
Martin Ndhlovu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pawel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!