This is my code, if I do not put conditions I get everything but I add a final comma and trying to filter the last position of i with an if () omits the last two numbers.
public class EjercicioFibonacci {
public static void main(String[] args) {
int a=0,b=1;
for (int i = 0; i < 4; i++) {
if (i==0) {
System.out.print(a+","+b+",");
}else if(i==3) {
a=a+b;
b=a+b;
System.out.print(a+","+b);
}else {
a=a+b;
b=a+b;
System.out.print(a+","+b+",");
}
}
}
}