{"id":15042821,"url":"https://github.com/venkatesh-bharath/sreamapi_java8_programming","last_synced_at":"2026-03-16T22:37:05.631Z","repository":{"id":249004434,"uuid":"830440557","full_name":"Venkatesh-Bharath/SreamAPI_Java8_Programming","owner":"Venkatesh-Bharath","description":"The Stream API in Java 8 provides a modern, functional approach to processing sequences of elements, such as collections. It allows for more concise, readable, and flexible code by using declarative operations. ","archived":false,"fork":false,"pushed_at":"2024-08-27T02:48:08.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T13:23:17.123Z","etag":null,"topics":["arrays","collections","java-8","numbers","pattren","streamapi","strings"],"latest_commit_sha":null,"homepage":"https://youtube.com/playlist?list=PLKZ1dSitnT23YRX_UPOjfSw050lN0-EtK\u0026si=krydJD2dQ6ozGk6G","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Venkatesh-Bharath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-18T09:23:19.000Z","updated_at":"2024-08-27T02:48:11.000Z","dependencies_parsed_at":"2024-08-27T04:19:03.717Z","dependency_job_id":null,"html_url":"https://github.com/Venkatesh-Bharath/SreamAPI_Java8_Programming","commit_stats":null,"previous_names":["venkatesh-bharath/stream-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Venkatesh-Bharath%2FSreamAPI_Java8_Programming","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Venkatesh-Bharath%2FSreamAPI_Java8_Programming/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Venkatesh-Bharath%2FSreamAPI_Java8_Programming/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Venkatesh-Bharath%2FSreamAPI_Java8_Programming/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Venkatesh-Bharath","download_url":"https://codeload.github.com/Venkatesh-Bharath/SreamAPI_Java8_Programming/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243451605,"owners_count":20293168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrays","collections","java-8","numbers","pattren","streamapi","strings"],"created_at":"2024-09-24T20:48:02.631Z","updated_at":"2025-12-29T23:05:12.106Z","avatar_url":"https://github.com/Venkatesh-Bharath.png","language":"Java","readme":"## Stream API\nThe Stream API in Java 8 provides a modern, functional approach to processing sequences of elements, such as collections. It allows for more concise, readable, and flexible code by using declarative operations.\n\n### Key Concepts\n\n- **Stream:** A sequence of elements supporting sequential and parallel aggregate operations.\n- **Intermediate Operations:** Return a new stream and are lazy (e.g., `filter`, `map`, `sorted`).\n- **Terminal Operations:** Produce a result or a side effect and terminate the stream (e.g., `forEach`, `collect`, `reduce`).\n\n### Example Usage\n\n#### Creating a Stream\n```java\nList\u003cString\u003e list = Arrays.asList(\"apple\", \"banana\", \"cherry\");\nStream\u003cString\u003e stream = list.stream();\n```\n\n#### Intermediate Operations\n\n- **filter:** Filters elements based on a condition.\n  ```java\n  List\u003cString\u003e filteredList = list.stream()\n                                  .filter(s -\u003e s.startsWith(\"a\"))\n                                  .collect(Collectors.toList());\n  // Output: [\"apple\"]\n  ```\n\n- **map:** Transforms each element.\n  ```java\n  List\u003cInteger\u003e lengths = list.stream()\n                              .map(String::length)\n                              .collect(Collectors.toList());\n  // Output: [5, 6, 6]\n  ```\n\n- **sorted:** Sorts the elements.\n  ```java\n  List\u003cString\u003e sortedList = list.stream()\n                                .sorted()\n                                .collect(Collectors.toList());\n  // Output: [\"apple\", \"banana\", \"cherry\"]\n  ```\n\n#### Terminal Operations\n\n- **forEach:** Performs an action for each element.\n  ```java\n  list.stream()\n      .forEach(System.out::println);\n  ```\n\n- **collect:** Accumulates the elements into a collection.\n  ```java\n  List\u003cString\u003e collectedList = list.stream()\n                                   .collect(Collectors.toList());\n  ```\n\n- **reduce:** Reduces the elements to a single value.\n  ```java\n  Optional\u003cString\u003e concatenated = list.stream()\n                                      .reduce((s1, s2) -\u003e s1 + \", \" + s2);\n  // Output: Optional[\"apple, banana, cherry\"]\n  ```\n\n### Advanced Example\n```java\nList\u003cEmployee\u003e employees = Arrays.asList(\n    new Employee(1, \"John\", 1000),\n    new Employee(2, \"Jane\", 1500),\n    new Employee(3, \"Jack\", 1200)\n);\n\n// Filter, map, and collect\nList\u003cString\u003e names = employees.stream()\n                              .filter(e -\u003e e.getSalary() \u003e 1100)\n                              .map(Employee::getName)\n                              .collect(Collectors.toList());\n// Output: [\"Jane\", \"Jack\"]\n\n// Sum salaries\nint totalSalary = employees.stream()\n                           .mapToInt(Employee::getSalary)\n                           .sum();\n// Output: 3700\n```\n\n### Benefits\n\n- **Conciseness:** Reduces boilerplate code.\n- **Parallelism:** Simplifies parallel processing.\n- **Readability:** Enhances readability with a functional approach.\n\nThe Stream API is a powerful tool in Java 8 for working with collections in a more functional and declarative manner.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenkatesh-bharath%2Fsreamapi_java8_programming","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvenkatesh-bharath%2Fsreamapi_java8_programming","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvenkatesh-bharath%2Fsreamapi_java8_programming/lists"}