Min sub array size with a given sum
1 Coding conventions

The Java coding conventions dictate that any for, if, while construct is preceded by a blank line. So instead of 

int dummy = 10;
for (int i = 0; i &lt; dummy; ++i) {
    ...
}


you should write 

int dummy = 10;

for (int i = 0; i &lt; dummy; ++i) {
    ...
}


Next, you have no space after the conditions of if statements: Instead of 

if (testCondition()){
    ...
}


you should write 

if (testCondition()) { // Note the space before '{'!
    ...
}


2 Algorithm

Printing to standard output in an algorithm is a no-no. Suppose you want to use your implementation in a real-world project. Apart from flooding the stdout, you waste time since calling System.out.print* goes down through the Java virtual machine straight to the OS, and is, thus, expensive. So, it would be nicer just return an integer whose value is the index of the leftmost element of the solution.

3 Summa summarum

All in all, I thought about this reimplementation:

public static int minSubArrayV2(final int[] array, final int targetSum) {
    if (targetSum == 0) {
        // Special case: return the index of the first array component whose 
        // value is zero.
        for (int i = 0; i &lt; array.length; ++i) {
            if (array[i] == 0) {
                return i;
            }
        }

        return -1;
    }

    if (targetSum &gt; 0) {
        for (int startIndex = 0; startIndex &lt; array.length; ++startIndex) {
            int sum = 0;

            for (int i = startIndex; i &lt; array.length; ++i) {
                sum += array[i];

                if (sum &gt; targetSum) {
                    break;
                } else if (sum == targetSum) {
                    return startIndex;
                }
            }
        }
    } else {
        for (int startIndex = 0; startIndex &lt; array.length; ++startIndex) {
            int sum = 0;

            for (int i = startIndex; i &lt; array.length; ++i) {
                sum += array[i];

                if (sum &lt; targetSum) {
                    break;
                } else if (sum == targetSum) {
                    return startIndex;
                }
            }
        }
    }

    return -1;
}      


Hope that helps.

A note

I spent about two hours thinking about how to improve the time complexity of your algorithm, and did not find any opportunity. However, you could spent \$\Theta(N^2)\$ for preprocessing the array, after which you can do queries in constant time. Consider the following:

public static Map&lt;Integer, Integer&gt; preprocessArray(final int[] array) {
    final Map&lt;Integer, Integer&gt; map = new HashMap&lt;&gt;();

    for (int startIndex = 0; startIndex &lt; array.length; ++startIndex) {
        int sum = 0;

        for (int i = startIndex; i &lt; array.length; ++i) {
            map.putIfAbsent(sum += array[i], startIndex);
        }
    }

    return map;
}

void foo(int[] array) {
    Map&lt;Integer, Integer&gt; map = preprocessArray(array);
    System.out.println(map.get(6));
}