Longest substring with 2 unique characters in a given string at linear time
Corner cases

You correctly handle the corner cases of too short input and null input.
But you forgot to handle the case of all same characters, for example "aaa".
On such input the program throws StringIndexOutOfBoundsException on line secondUnique = s.charAt(i);.

Variable scope

The variable c is only needed within the main for loop,
so it would be best to declare it inside the loop.

Style

This is fine:


for (; (i &lt; len) &amp;&amp; (s.charAt(i) == firstUnique); i++);



But it looks a bit strange.
A for loop is easiest to read in its most classing form a counting loop:
it performs some initialization,
then on each iteration it does its main work in the body.
Here, the main work to do is the counting.
So if you transform this to a while loop with a body,
it becomes slightly easier to read.