Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kunals201's full-sized avatar

Kunal sethi kunals201

View GitHub Profile
@kunals201
kunals201 / Test.java
Last active May 1, 2018 11:44
NoDefFoundError problem last class
import pack2.Demo2;
class Test {
public static void main(String[] args) {
System.out.println("Test class main");
Demo2 obj = new Demo2();
obj.test2();
}
}
@kunals201
kunals201 / Demo2.java
Last active May 1, 2018 11:45
NoDefFoundErrorProblem
package pack2;
import pack1.Demo1;
public class Demo2 {
public void test2()
{
System.out.println("pack2.Demo2 method");
Demo1 obj = new Demo1();
obj.test();
}
@kunals201
kunals201 / Demo1.java
Last active May 1, 2018 11:46
Demo1.java
package pack1;
public class Demo1
{
public void test()
{
System.out.println("pack1.test");
}
}
@kunals201
kunals201 / IfPresentOrElseExample.java
Created March 29, 2018 07:33
Imperative style example of ifPresent
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());
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();
@kunals201
kunals201 / IntStreamIterateExample.java
Last active March 27, 2018 11:10
example of IntStream iterate
public class IntStreamIterateExample {
public static void main(String[] args) {
IntStream.iterate(0, i -> i<5, i -> i+2 )
.forEach(System.out::println);
}
}
@kunals201
kunals201 / DropWhileExample.java
Created March 27, 2018 08:37
Example of dropWhile method
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);
}
@kunals201
kunals201 / SkipExample.java
Created March 27, 2018 08:30
Skip(count) example
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);
}
@kunals201
kunals201 / takewhile.java
Created March 27, 2018 06:57
takeWhile Example
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);
}
@kunals201
kunals201 / limit.java
Created March 16, 2018 10:55
limit method example
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);
}