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 pack2.Demo2; | |
class Test { | |
public static void main(String[] args) { | |
System.out.println("Test class main"); | |
Demo2 obj = new Demo2(); | |
obj.test2(); | |
} | |
} |
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
package pack2; | |
import pack1.Demo1; | |
public class Demo2 { | |
public void test2() | |
{ | |
System.out.println("pack2.Demo2 method"); | |
Demo1 obj = new Demo1(); | |
obj.test(); | |
} |
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
package pack1; | |
public class Demo1 | |
{ | |
public void test() | |
{ | |
System.out.println("pack1.test"); | |
} | |
} |
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 IfPresentOrElseExample { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(10, 20, 30, 40, 50, 60, 70, 80, 90); | |
Optional<Integer> first = numbers.stream().filter(a -> a > 500).findFirst(); | |
if (first.isPresent()) { | |
System.out.println(first.get()); |
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 IfPresentExample { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(10, 20, 30, 40, 50, 60, 70, 80, 90); | |
Optional<Integer> first = numbers.stream().filter(a -> a > 500).findFirst(); | |
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); | |
} | |
} |
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 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 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 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); | |
} |