Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Term Entry] Java ArrayList .removeAll() #4581

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bpicoCode
Copy link
Contributor

Description

  • Adding a new term entry for ArrayList .removeAll() method

Issue Solved

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@CLAassistant
Copy link

CLAassistant commented Apr 26, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ bpicoCode
❌ Ben Picone


Ben Picone seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mamtawardhani mamtawardhani self-assigned this Apr 27, 2024
@mamtawardhani mamtawardhani added java Java entries new entry New entry or entries status: under review Issue or PR is currently being reviewed labels Apr 27, 2024
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bpicoCode!
Thank you for contributing to Codecademy Docs! The entry is well written!

I've suggested a few changes, could you please review and modify them at your earliest convenience?
Thank you!

Co-authored-by: mamtawardhani <53176352+mamtawardhani@users.noreply.github.com>
@bpicoCode
Copy link
Contributor Author

@mamtawardhani Suggestions committed!

Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bpicoCode, just one change is required, please review and modify it!
Thanks!

Co-authored-by: mamtawardhani <53176352+mamtawardhani@users.noreply.github.com>
Copy link
Collaborator

@mamtawardhani mamtawardhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for the second review

Copy link
Collaborator

@avdhoottt avdhoottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bpicoCode, I suggested some changes, please make them.

@@ -0,0 +1,68 @@
---
Title: '.removeAll()'
Description: 'Removes multiple elements from an ArrayList.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: 'Removes multiple elements from an ArrayList.'
Description: 'Removes multiple elements from an ArrayList that are also contained in the specified collection.'

The previous description didn't give the whole working of the method.


## Syntax

A collection of elements, specified by `Collection c`, can be removed from an `ArrayList` instance using the `.removeAll()` method:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line and add the description of the parameters ArrayList2 and ArrayList1 below the syntax in this format -

- `parameterName`: Parameter description.
- `parameterName`: Parameter description.

A collection of elements, specified by `Collection c`, can be removed from an `ArrayList` instance using the `.removeAll()` method:

```pseudo
arrayListInstance.removeAll(Collection c);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
arrayListInstance.removeAll(Collection c);
ArrayList1.removeAll(ArrayList2);

Simply the syntax as much as possible.

Comment on lines +32 to +60
import java.util.ArrayList;

public class RemoveFallMonths{
public static void main(String[] args) {

ArrayList<String> fallMonths = new ArrayList<String>();

fallMonths.add("August");
fallMonths.add("September");
fallMonths.add("October");
fallMonths.add("November");
fallMonths.add("December");

ArrayList<String> monthsToRemove = new ArrayList<String>();

monthsToRemove.add("August");
monthsToRemove.add("December");

// Remove August and December from fallMonths using monthsToRemove
fallMonths.removeAll(monthsToRemove);

System.out.println("After removing specified months: " + fallMonths);```

// Remove all elements from fallMonths
fallMonths.removeAll(fallMonths);

System.out.println("After removing all elements: " + fallMonths);```
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import java.util.ArrayList;
public class RemoveFallMonths{
public static void main(String[] args) {
ArrayList<String> fallMonths = new ArrayList<String>();
fallMonths.add("August");
fallMonths.add("September");
fallMonths.add("October");
fallMonths.add("November");
fallMonths.add("December");
ArrayList<String> monthsToRemove = new ArrayList<String>();
monthsToRemove.add("August");
monthsToRemove.add("December");
// Remove August and December from fallMonths using monthsToRemove
fallMonths.removeAll(monthsToRemove);
System.out.println("After removing specified months: " + fallMonths);```
// Remove all elements from fallMonths
fallMonths.removeAll(fallMonths);
System.out.println("After removing all elements: " + fallMonths);```
}
}
import java.util.ArrayList;
public class RemoveFallMonths{
public static void main(String[] args) {
ArrayList<String> fallMonths = new ArrayList<String>();
fallMonths.add("August");
fallMonths.add("September");
fallMonths.add("October");
fallMonths.add("November");
fallMonths.add("December");
ArrayList<String> monthsToRemove = new ArrayList<String>();
monthsToRemove.add("August");
monthsToRemove.add("December");
// Remove August and December from fallMonths using monthsToRemove
fallMonths.removeAll(monthsToRemove);
System.out.println("After removing specified months: " + fallMonths);
// Remove all elements from fallMonths
fallMonths.removeAll(fallMonths);
System.out.println("After removing all elements: " + fallMonths);
}
}

The code had some errors, but I fixed them.

Comment on lines +66 to +67
[September, October, November]
[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[September, October, November]
[]
After removing specified months: [September, October, November]
After removing all elements: []

This is the complete output.

}
```

The `RemoveFallMonths` output should look like this:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `RemoveFallMonths` output should look like this:
The output of the above code should look like this:

@avdhoottt
Copy link
Collaborator

Hey @bpicoCode, it's been two weeks since I suggested the changes, are you still working on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants