declaring remove  
Author Message
ste1986





PostPosted: 2006-1-11 4:28:00 Top

java-programmer, declaring remove do i have to declare remove when trying to remove from an ArrayList or
should java know what this does?

e.g person.remove

 
James Westby





PostPosted: 2006-1-11 4:40:00 Top

java-programmer >> declaring remove ste1986 wrote:
> do i have to declare remove when trying to remove from an ArrayList or
> should java know what this does?
>
> e.g person.remove
>

No, java will know about it but you have to call it properly,

e.g.

person.remove(0);

to remove the first element.

See
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html#remove(int)

James
 
Roedy Green





PostPosted: 2006-1-11 4:48:00 Top

java-programmer >> declaring remove On Tue, 10 Jan 2006 15:27:45 -0500, "ste1986" <email***@***.com>
wrote, quoted or indirectly quoted someone who said :

>do i have to declare remove when trying to remove from an ArrayList or
>should java know what this does?
>
>e.g person.remove

Look at the JavaDoc to see what methods come builtin. You also have
to look at the superclasses. You will discover remove is part of
ArrayList.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
 
Mark Thomas





PostPosted: 2006-1-11 5:03:00 Top

java-programmer >> declaring remove ste1986 wrote:
> do i have to declare remove when trying to remove from an ArrayList or
> should java know what this does?
>
> e.g person.remove
>
Once again, you ask a question without any of the information needed to
answer it. Are you reading the replies people are giving you? It is
obvious that you need to go back & learn basic Java. The remove method,
like all other methods, needs to have the brackets to identify it as a
method, rather than a field.

If your ArrayList was declared like this:

ArrayList<Person> persons = new ArrayList<Person>();

or this:

ArrayList persons = new ArrayList();

then to remove a person from it you would use:

persons.remove(aPerson);

Note that you're passing the Object you want to remove to the ArrayList
you want to remove it from. Look up the API for java.util.ArrayList and
you'll see the method there. Read it.

Now go back and read Thomas Weidenfeller's reply to you posted earlier
today or everybody will start ignoring you.

Mark
 
 
Roedy Green





PostPosted: 2006-1-11 5:28:00 Top

java-programmer >> declaring remove On Tue, 10 Jan 2006 21:03:13 +0000, Mark Thomas <anon> wrote, quoted
or indirectly quoted someone who said :

>The remove method,
>like all other methods, needs to have the brackets to identify it as a
>method, rather than a field.

[] are brackets. They are used for array indices in Java. I think you
meant () parentheses, which are the method indicator. {} are called
braces.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
 
Daniel Dyer





PostPosted: 2006-1-11 6:17:00 Top

java-programmer >> declaring remove On Tue, 10 Jan 2006 21:28:20 -0000, Roedy Green
<email***@***.com> wrote:

> On Tue, 10 Jan 2006 21:03:13 +0000, Mark Thomas <anon> wrote, quoted
> or indirectly quoted someone who said :
>
>> The remove method,
>> like all other methods, needs to have the brackets to identify it as a
>> method, rather than a field.
>
> [] are brackets. They are used for array indices in Java. I think you
> meant () parentheses, which are the method indicator. {} are called
> braces.

I Britain we generally call '(' and ')' brackets. '[' and ']' are square
brackets. We rarely use the word 'parentheses'. '{' and '}' are commonly
referred to as curly brackets or curly braces, although I don't recall
seeing them referred to outside of a programming context.

See
http://www.askoxford.com/asktheexperts/jargonbuster/b-c/brackets?view=uk

Dan.

--
Daniel Dyer
http://www.dandyer.co.uk
 
 
Roedy Green





PostPosted: 2006-1-11 6:59:00 Top

java-programmer >> declaring remove On Tue, 10 Jan 2006 22:17:14 -0000, "Daniel Dyer"
<email***@***.com> wrote, quoted or indirectly
quoted someone who said :

>I Britain we generally call '(' and ')' brackets. '[' and ']' are square
>brackets. We rarely use the word 'parentheses'. '{' and '}' are commonly
>referred to as curly brackets or curly braces, although I don't recall
>seeing them referred to outside of a programming context.

Common usage causes confusion. Until is started using computers () []
and {} were all just brackets. I can still recall my pendantic friend
Hugh McDonald lecturing me on the precise computer terminology, which
predates Java. I gather ASCII may have defined the official names. The
JLS is quite meticulous about using the convention I described.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
 
Mark Thomas





PostPosted: 2006-1-11 17:24:00 Top

java-programmer >> declaring remove Roedy Green wrote:
> On Tue, 10 Jan 2006 22:17:14 -0000, "Daniel Dyer"
> <email***@***.com> wrote, quoted or indirectly
> quoted someone who said :
>
>
>>I Britain we generally call '(' and ')' brackets. '[' and ']' are square
>>brackets. We rarely use the word 'parentheses'. '{' and '}' are commonly
>>referred to as curly brackets or curly braces, although I don't recall
>>seeing them referred to outside of a programming context.
>
>
> Common usage causes confusion. Until is started using computers () []
> and {} were all just brackets. I can still recall my pendantic friend
> Hugh McDonald lecturing me on the precise computer terminology, which
> predates Java. I gather ASCII may have defined the official names. The
> JLS is quite meticulous about using the convention I described.

Thanks for that Roedy, it's good to know. However, the conventions
Daniel described are so entrenched here in Britain that people would
misunderstand me if I used the ones you describe. I'll remember the
possible confusion when I post to usenet though.

Mark