-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay50_prob2.java
55 lines (39 loc) · 949 Bytes
/
Day50_prob2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Ram asked hari ,you speak sentence and i will count the number of words present in that sentence.
Help rama to write this program using lambda Expresssion.
Input Format
First line will accept a String
Example
Input
====
I am a boy
Outpt
=====
4
Constraints
input must be a string
Output Format
output will be the number of words present in the string
Sample Input 0
i am a student
Sample Output 0
4
*/
// Kirtan Jain
import java.io.*;
import java.util.*;
interface Int {
int method(String str);
}
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String st = sc.nextLine();
Int obj = (str)->{
String[] s = str.split(" ");
return s.length;
};
System.out.println(obj.method(st));
}
}