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
base: main
Are you sure you want to change the base?
Conversation
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. |
There was a problem hiding this 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>
@mamtawardhani Suggestions committed! |
There was a problem hiding this 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>
There was a problem hiding this 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
There was a problem hiding this 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.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrayListInstance.removeAll(Collection c); | |
ArrayList1.removeAll(ArrayList2); |
Simply the syntax as much as possible.
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);``` | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
[September, October, November] | ||
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `RemoveFallMonths` output should look like this: | |
The output of the above code should look like this: |
Hey @bpicoCode, it's been two weeks since I suggested the changes, are you still working on this PR? |
Description
Issue Solved
Type of Change
Checklist
main
branch.Issues Solved
section.