Static-NonStatic Order of execution

class New{

	//Constructor
	public New(){
		System.out.println("Constructor");
	}

	//Method
	public void method(){
		System.out.println("method");
	}

	//Non-Static Block
	{

		System.out.println("Non-Static");
	}

	//Static Block
	static
	{

		System.out.println("Static");
	}
}
public class StatisNonstatic {

	public static void main(String[] args) {
		System.out.println("Main");
		New n = new New();
		n.method();
	}

}

JAVA - Extract File Name From A File Path

public class MajorExtractFileName {

	/**
	 * @author Rakesh KR
	 */
	public static void main(String[] args) {
		
		String str       = "C:/Users/sixdee/Documents/Linux commands a world of power and control._files/freeAd2.jpg";
		String string[]  = str.split("/");
		String newString = "";
		String tmpString = "";
		int noOfDirAway  = 0;
		int  n           = noOfDirAway+2;
		for(int i=string.length-1;i>string.length-n;i--){
			newString = "/"+string[i];
			tmpString = newString+tmpString;
		}
		String ansString = tmpString.replaceFirst("/", " ");
		System.out ...

Java Compress And Decompress a String

import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * @author Rakesh KR
 */

public class CompressDecompress {

	public static String encode(String source) {
		StringBuffer dest = new StringBuffer();
		for (int i = 0; i < source.length(); i++) {
			int runLength = 1;
			while (i+1 < source.length() && source.charAt(i) == source.charAt(i+1)) {
				runLength ...