Skip to content

Commit

Permalink
feat: Add java 8 question asked in interview
Browse files Browse the repository at this point in the history
  • Loading branch information
VishwajeetVT committed Nov 18, 2024
1 parent c9cf97e commit 0f90763
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.practice.dsa.java8.functional_programming.interview;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Reverse {
// Given the list of strings, reverse the characters of String element of list not the order
public static void main(String[] args) {
List<String> list = Arrays.asList("Welcome", "to", "Java");
System.out.println(reverseString(list));
}

public static List<String> reverseString(List<String> list) {
return list.stream()
.map(str -> new StringBuilder(str).reverse().toString())
.collect(Collectors.toList());
}
}

0 comments on commit 0f90763

Please sign in to comment.