Skip to content

Tag: example

Chain of Promises Example

const f1 = async() => {
    setTimeout( () => {
        console.log("f1");
    }, 100)
};

const f2 = async() => {
    setTimeout( () => {
        console.log("f2");
    }, 100)
};

const f3 = async() => {
    return new Promise((resolve, reject) => {
        reject("f3");
    });
};

const f4 = async() => {
    setTimeout( () => {
        console.log("f4");
    }, 100)
};

const workflow = async () => {
    await f1();
    await f2();
    await f3();
    await f4();
};

workflow().catch((error)=>{
    console.error(error);
})

Integer.MAX_VALUE and Integer.MIN_VALUE

You should know that variable values are cyclic in Java.

public class Test{
  public static void main(String args[]){
     System.out.println(Integer.MAX_VALUE);
     System.out.println(Integer.MIN_VALUE);
     int x = Integer.MAX_VALUE + 1;
     System.out.println(x);
  }
}

This produces:

2147483647
-2147483648
-2147483648