Author Archives: Stanislav_Panteleev

Java.Java8.How can I get the average of all numbers?

✅ Example: Average of All Numbers in a Set 🔹 Output:

Posted in Без рубрики | Comments Off on Java.Java8.How can I get the average of all numbers?

Java.Java8.How can I get the sum of all numbers in a set?

✅ Example: Sum of All Numbers in a Set 🔹 Output: ✅ Breakdown Method Description stream() Turns the Set into a Stream mapToInt() Converts Integer objects to primitives sum() Sums all elements in the IntStream 🧠 Bonus: Using reduce() If … Continue reading →

Posted in Без рубрики | Comments Off on Java.Java8.How can I get the sum of all numbers in a set?

Java.Java8.How can I find the minimum number in a set?

To find the minimum number in a Set, you can use the min() method in a stream — just like you did with max(). ✅ Example: Find Min in a Set 🔹 Output: ✅ Explanation Method Purpose .stream() Turns the … Continue reading →

Posted in Без рубрики | Comments Off on Java.Java8.How can I find the minimum number in a set?

Java.Java8.How can I find the maximum number in a set?

👑 To find the maximum number in a Set using Java Streams, you can use the max() terminal method with a comparator. ✅ Example: Find Max in a Set 🔹 Output: ✅ Explanation: .stream() – converts the Set to a … Continue reading →

Posted in Без рубрики | Comments Off on Java.Java8.How can I find the maximum number in a set?

Java.Java8.How can I display 10 random numbers in ascending order?

👌 To display 10 random numbers in ascending order, you can: Generate 10 random numbers, Sort them using sorted(), Print them using forEach(). ✅ Example Using Random and Streams

Posted in Без рубрики | Comments Off on Java.Java8.How can I display 10 random numbers in ascending order?

Java.Java8.How can I display the number of empty strings using the filter() method?

✅ Goal: Use filter() to keep only empty strings. Use count() to get the number of them. 🔹 Example: 🔹 Output: ✅ Breakdown: filter(String::isEmpty): keeps only strings that are “” count(): returns the total number of elements remaining after filtering

Posted in Без рубрики | Comments Off on Java.Java8.How can I display the number of empty strings using the filter() method?

Java.Java8.How can I display unique squares of numbers using the map() method?

✅ Goal: Square each number in a list. Remove duplicates (make them unique). Print them using forEach().

Posted in Без рубрики | Comments Off on Java.Java8.How can I display unique squares of numbers using the map() method?

Java.Java8.How can I display 10 random numbers using forEach()?

✅ Example using Stream.generate() 🔹 Breakdown: Stream.generate(…): creates an infinite stream random.nextInt(100): generates a random number between 0 and 99 limit(10): keeps only the first 10 forEach(…): prints them one by one

Posted in Без рубрики | Comments Off on Java.Java8.How can I display 10 random numbers using forEach()?

Java.Java8.What intermediate methods for working with streams do you know?

✅ Common Intermediate Stream Methods Here’s a full list of the most important ones grouped by purpose: 🔹 1. Transformation Method Description map() Transforms each element flatMap() Flattens nested streams mapToInt(), mapToDouble(), mapToLong() Special for primitives

Posted in Без рубрики | Comments Off on Java.Java8.What intermediate methods for working with streams do you know?

Java.Java8.What final methods for working with streams do you know?

🔹 1. Collecting Results Method Description collect() Accumulates elements into a collection (like List, Set, Map) toArray() Converts the stream into an array Example:

Posted in Без рубрики | Comments Off on Java.Java8.What final methods for working with streams do you know?