This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.stream.Stream; | |
public class WordCount { | |
public static void main(String[] args) throws FileNotFoundException { | |
countWords("sample.txt"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.stream.Stream; | |
public class WordCount { | |
public static void main(String[] args) throws FileNotFoundException { | |
countWords("sample.txt"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.util.stream.Stream; | |
public class WordCount { | |
public static void main(String[] args) throws IOException { | |
countWords("sample.txt"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Util { | |
default int numberOfStudents() { | |
return helper(); | |
} | |
private int helper() { | |
return 10; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sample { | |
public static void main(String[] args) { | |
int _ = 4; | |
System.out.println(_); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Limit { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(11,22,33,44,55,66,77,88,99); | |
numbers.stream() | |
.limit(4) | |
.forEach(System.out::println); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sample { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(11, 22, 33, 44, 55, 66, 77, 88, 99); | |
numbers.stream() | |
.takeWhile(e -> e < 66) | |
.forEach(System.out::println); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SkipExample { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(11, 22, 33, 44, 55, 66, 77, 88, 99); | |
numbers.stream() | |
.skip(5) | |
.forEach(System.out::println); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DropWhileExample { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(11, 22, 33, 44, 55, 66, 77, 88, 99); | |
numbers.stream() | |
.dropWhile(e -> e < 55) | |
.forEach(System.out::println); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntStreamIterateExample { | |
public static void main(String[] args) { | |
IntStream.iterate(0, i -> i<5, i -> i+2 ) | |
.forEach(System.out::println); | |
} | |
} |
OlderNewer