Skip to content

learn-co-curriculum/java-mod-4-lambda-scope-lab

Repository files navigation

Lambda Scope Lab

Instruction

You’re given this starter code:

public interface StringOperator {
  String apply(String s);
}
public class Main {
  String PREFIX = "__prefix__";
  String SUFFIX = "__suffix__";

  // fix the scope error and remove whitespace from str
  public static StringOperator operator = str -> PREFIX + str + SUFFIX;

  public static void main(String[] args) {
    String res = operator.apply("  hello there  ");
    System.out.println(res); // __prefix__hellothere__suffix__
  }
}

Your tasks are to:

  • Fix the modifiers of the PREFIX and SUFFIX variables to remove the scope error in the operator lambda expression.
  • Update the lambda expression to remove all whitespace from str.

Resources

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages