How does this line work in printing an horizontal hourglass?(this code is from editorial of challenge set 1)

int cst = 1;
if (row == n + 1) {
cst = 2;
val += 2;
} else {
cst = 1;
val++;
}

		// work for numbers
		for (; cst <= nst; cst++) {
			System.out.print(val + " ");
			val++;
		}

Give me the full code for this which is runnable on the ide