Monday, 29 June 2015

Java Lambda Demo

public class LamdaDemo {
   public static void main(String args[]){
      LamdaDemo lamda = new LamdaDemo();

      //type declaration
      BasicMaths add = (int a, int b) -> a + b;

      //no type declaration
      BasicMaths subtract = (a, b) -> a - b;

      //with return statement
      BasicMaths product = (int a, int b) -> { return a * b; };
      
      BasicMaths quotient = (int a, int b) -> a / b;

      System.out.println("1 + 1 = " + lamda.operate(1, 1, add));    
      System.out.println("1 - 1 = " + lamda.operate(1, 1, subtract));
      System.out.println("1 x 1 = " + lamda.operate(1, 1, product));
      System.out.println("1 / 1 = " + lamda.operate(1, 1, quotient));

       
   }   

   interface BasicMaths {
      int execute(int a, int b);
   }  

  
   private int operate(int a, int b, BasicMaths basicMaths){
      return basicMaths.execute(a, b);
   } 
}

Saturday, 6 June 2015

How to capture Android Screenshots using batch programming.


Open any editor(I prefer Notepad) and create a .bat file

Add this source code

********************************************************
@echo off
echo This script will capture a screenshot of your android phone...
echo Trying to capture your screen
adb shell screencap -p /sdcard/screenshot.png
echo saving to your computer
adb pull /sdcard/screenshot.png
echo deleting residuals from your phone
adb shell rm -r /sdcard/screenshot.png
echo done
exit
***********************************************************

Save the file now.

Double click to open the file, or open via cmd

Voila!