Aqui tienes amigo :)
public class Program
{
public static void main(String[] args) {
int n1 = 1, n2 = 5, i=1;
while(true){
if(i % 2 != 0){
for(int k = n1 ; k<= n2 ; k++){
System.out.print(k+" ");
}
n1++;
System.out.println();
}
else{
for(int k = n2 ; k>= n1 ; k--){
System.out.print(k+" ");
}
n2--;
System.out.println();
}
if(n1 == n2){
System.out.print(n1);
break;
}
i++;
}
}
}