Skip to content

Conversation

@durgesh137
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings December 4, 2025 04:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new problem (Q005) demonstrating string filtering with lambdas and Stream API. It introduces functionality to search for substrings within string arrays, comparing traditional loop-based approaches with Java 8 Stream API implementations.

Key changes:

  • Added utility methods for string array generation and printing
  • Implemented traditional and stream-based substring filtering examples
  • Created comprehensive performance comparison with multiple dataset sizes (20 to 1M strings)

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
ComparisonUtils.java Added string sample data array and three utility methods: printStrings(), getStringArrayWithPatternAtEnd(), and getStringArray()
PrintStringsTraditional.java Implements traditional for-loop approach for filtering strings by substring
PrintStringsStream.java Implements Stream API approach with filter() and contains() for substring matching
PrintStringsComparison.java Benchmarks both approaches with test cases ranging from 20 to 1,000,000 strings
README.md Updated documentation to include Q005, new utility methods, and string operation concepts
PROBLEMS.md Added Q005 problem statement and updated utility method documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
System.out.println("]\n");
}

Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing JavaDoc documentation for the getStringArrayWithPatternAtEnd method. All other public methods in this class have JavaDoc comments with @param and @return tags.

Suggested change
/**
* Generates an array of strings of the specified size, with some elements containing the given pattern at the end.
* @param size the number of strings to generate
* @param pattern the pattern to append to some strings
* @return an array of strings, some of which have the pattern appended at the end
*/

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +26
if(str.contains(substring))
System.out.print(str+",");
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Missing braces for if statement. According to Java best practices, single-line if statements should include braces for better readability and maintainability. Should be:

if(str.contains(substring)) {
    System.out.print(str+",");
}
Suggested change
if(str.contains(substring))
System.out.print(str+",");
if(str.contains(substring)) {
System.out.print(str+",");
}

Copilot uses AI. Check for mistakes.
* 2. Print each string to the console.
*/
for (String str : strings) {
if(str.contains(substring))
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing space after if keyword. Should be if (str.contains(substring)) with a space before the opening parenthesis, following Java style conventions.

Suggested change
if(str.contains(substring))
if (str.contains(substring))

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +30
.filter(n->n.contains(subString))
.forEach(n->System.out.print(n+","));
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing space in lambda expression arrow operator. Should be .filter(n -> n.contains(subString)) with spaces around the arrow operator for consistency with Java lambda style conventions.

Suggested change
.filter(n->n.contains(subString))
.forEach(n->System.out.print(n+","));
.filter(n -> n.contains(subString))
.forEach(n -> System.out.print(n+","));

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +30
.filter(n->n.contains(subString))
.forEach(n->System.out.print(n+","));
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing space in lambda expression arrow operator. Should be .forEach(n -> System.out.print(n+",")) with spaces around the arrow operator for consistency with Java lambda style conventions.

Suggested change
.filter(n->n.contains(subString))
.forEach(n->System.out.print(n+","));
.filter(n -> n.contains(subString))
.forEach(n -> System.out.print(n+","));

Copilot uses AI. Check for mistakes.
* Traditional approach to print all strings in an array.
* Steps:
* 1. Use a for-each loop to iterate through each string in the array.
* 2. Print each string to the console.
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Misleading documentation comment. Step 2 states "Print each string to the console" but the method actually prints only strings that contain the specified substring. Update to: "2. Print strings that contain the substring to the console."

Suggested change
* 2. Print each string to the console.
* 2. Print strings that contain the substring to the console.

Copilot uses AI. Check for mistakes.

public static void main(String[] args) {
System.out.println("Q005: Print All Strings containing substring '_test' using Stream API");
ComparisonUtils.repeat("-",80);;
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Double semicolon detected on line 14. Remove the extra semicolon at the end of this line.

Suggested change
ComparisonUtils.repeat("-",80);;
ComparisonUtils.repeat("-",80);

Copilot uses AI. Check for mistakes.
//{"Apple_test", "Banana", "Cherry_test", "Date", "Elderberry", "Fig_test", "Grape", "Honeydew_test"};
String subString = "_test";

System.out.println("Input with length "+strings.length+": ");
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing space after + operator. Should be "Input with length " + strings.length + ": " with spaces around the concatenation operators for consistency.

Suggested change
System.out.println("Input with length "+strings.length+": ");
System.out.println("Input with length " + strings.length + ": ");

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +27
searchStrings(strings, subString);
}


public static void searchStrings(String[] strings, String subString){
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Method naming inconsistency. In PrintStringsStream.java, the method is named searchStrings() while in PrintStringsTraditional.java, it's named printStrings(). Both methods have the same purpose (filtering and printing strings with a substring). For consistency and clarity, they should have the same name. Consider using printStringsWithSubstring() or filterAndPrintStrings() for both.

Suggested change
searchStrings(strings, subString);
}
public static void searchStrings(String[] strings, String subString){
printStringsWithSubstring(strings, subString);
}
public static void printStringsWithSubstring(String[] strings, String subString){

Copilot uses AI. Check for mistakes.
}
return result;
}

Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

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

Missing JavaDoc documentation for the new printStrings method. All other public methods in this class have JavaDoc comments with parameter descriptions.

Suggested change
/**
* Prints the elements of a string array in a formatted manner.
* @param strings the array of strings to print
*/

Copilot uses AI. Check for mistakes.
@durgesh137 durgesh137 merged commit be227c1 into main Dec 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants