This file contains hidden or 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
@Test | |
void callingBlockingCodeInReactiveStreams() { | |
Mono.fromCallable(() -> { | |
// Your blocking code here | |
return new Object(); | |
}).subscribeOn(Schedulers.boundedElastic()); | |
Flux.fromIterable(Stream.of(1, 2, 3, 4, 5).map(i -> { | |
// Your blocking code here | |
return new Object(); |
This file contains hidden or 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.Serializable; | |
/** | |
* URL: https://leetcode.com/problems/valid-palindrome/ | |
*/ | |
public class ValidPalindrome implements Serializable { | |
public boolean isPalindrome1(String s) { | |
s = s.trim().replaceAll("\\W", "").replaceAll("_", "").toLowerCase(); | |
int length = s.length(); |
This file contains hidden or 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.util.ArrayList; | |
import java.util.Collection; | |
import java.util.List; | |
import java.util.Scanner; | |
import java.util.stream.Collectors; | |
public class DiagonalEncoderDecoder { | |
/** | |
* String = "my name is" |
This file contains hidden or 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
/* | |
Question: you have an array of integers and an array of sort order. You have to sort input array according | |
to that sort order. Those numbers don't belongs to order list will sort ascending order and will add at | |
the last of the result. | |
Example: | |
Input: [2, 3, 8, 4, 3, 5, 2, 7, 6, 2, 3, 5, 4, 1] | |
Order: [5, 2, 3] | |
Output: [5, 5, 2, 2, 2, 3, 3, 3, 1, 4, 4, 6, 7, 8] | |
*/ | |
import java.util.ArrayList; |
This file contains hidden or 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
/* | |
Question: you have an array of string and you have to sort them according to their size. | |
Example: | |
Input: ["ab", "a", "abc", "z", "abcd", "mp"]; | |
Output: ["a", "z", "ab", "mp", "abc", "abcd"] | |
*/ | |
import java.util.Comparator; | |
import java.util.List; | |
import java.util.stream.Collectors; |
This file contains hidden or 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 PolymorphicMethodOverloading { | |
public static void main(String[] args) { | |
Consumer consumer = new Consumer(); | |
Parent p1 = new Parent(); | |
Parent p2 = new Child1(); | |
Parent p3 = new Child2(); | |
Child1 p4 = new Child1(); | |
Child2 p5 = new Child2(); |
This file contains hidden or 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.util.Scanner; | |
/** | |
* @author ashik | |
* | |
*/ | |
public class Main { | |
/** | |
* @param args |
This file contains hidden or 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 com.studevs.example.test.core; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
System.out.print("Please type your name: "); |
This file contains hidden or 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.File; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.URL; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class Main { | |
public static void main(String[] args) throws IOException { |
This file contains hidden or 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.InputStream; | |
import java.net.URL; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class Main { | |
public static void main(String[] args) { | |
String from = "https://download.gimp.org/mirror/pub/gimp/v2.8/gimp-2.8.10.tar.bz2"; |
NewerOlder