Transform values with a stream
The goal is to transform an array of numbers into a comma-delimited string using functional programming. The code snippet you provided has a minor issue: String.join(",", strings[0]) is incorrect because it tries to join a single element ( strings[0] ) rather than all elements in the strings array. Here's the corrected code for the transformValues method: import java.util.Arrays; class Answer { // Change these boolean values to control whether you see // the expected answer and/or hints. static boolean showExpectedResult = true; static boolean showHints = true; // Transform an array of numbers into a comma-delimited list // using functional programming. static String transformValues(int[] numbers) { // Convert the int array to a stream of integers // Map each integer to its String representation // ...
Comments
Post a Comment