Here is the condition:

You need to write your own functional interface (TernaryIntPredicate) and use it with a lambda expression. The test method must be a single one.

Besides, you need to write down your argument using your TernaryIntPredicate.

The lambda expression is true otherwise. The name of the instance is allValuesAreDifferentPredicate. It should be a static field. Important. Use the provided template for your solution. Do not change it!
Sample Input 1: 1 1 1
Sample Output 1: False
Sample Input 2: 2 3 4
Sample Output 2: True

Here is the starting code:

@FunctionalInterface public interface TernaryIntPredicate { // Write a method here } public static final TernaryIntPredicate allValuesAreDifferentPredicate = // Write a lambda expression here 

Closed due to the fact that off-topic participants post_zeew , Kromster , Viktor Tomilov , cheops , default locale 1 Feb '18 at 4:49 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- post_zeew, Viktor Tomilov, cheops
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • What is the question / problem? - default locale
  • Yes, I figured it out already, thank you, here’s the final code (the part that was not implemented below by Vlad), everything compiles into Intellij Idea, but in Stepik (where you need to drive the code for verification), it still produces errors: public static void main (String [] args) {Scanner scan = new Scanner (System.in); int first = scan.nextInt (); int second = scan.nextInt (); int third = scan.nextInt (); System.out.println (allValuesAreDifferentPredicate.test (first, second, third)); } - Victor Kondratyuk

1 answer 1

 @FunctionalInterface public interface TernaryIntPredicate { boolean test(int first, int second, int third); } class Main { public static final TernaryIntPredicate allValuesAreDifferentPredicate = (first, second, third) -> first != second && first != third && second != third; public static void main(String[] args) { System.out.println(allValuesAreDifferentPredicate.test(1,1,1)); System.out.println(allValuesAreDifferentPredicate.test(2,3,4)); } } 
  • there is a slightly different task. It is necessary to enter through the console 3 any numbers, then, in case they are equal (as in the example 1 1 1), then false, if not - true. I understand this through the Scanner must be done. - Victor Kondratyuk
  • @Viktor Kondratyuk in the text given you the task is exactly the one to which the answer is given. - Sergey Gornostaev
  • @ VladLeonidov At the bottom of the task, Sample Input is written - this is a sample data entry. The user must enter three values ​​into the console and in return receive true or false. Thanks anyway, your version is close to true. - Victor Kondratyuk
  • The task does not indicate exactly how the input should be made, and this is an example for you, well, I think you can do the fastening of reading from the console. - Vlad Leonidov