public void print_star(int star)
{
if (star == 0) return;
System.out.print("* ");
print_star(star - 1);
}
When I send the value 5 to this code, it outputs "* * * * * * ". I want to write a Junit code for this, but since it returns void type, I wrote in Junit;
@Test
void printStar() {
var printStar=new Star();
printStar.print_star(5);
assertEquals("* * * * * ",printStar.print_star(5));
}
this code gives an error because it cannot compare void type and String. Is there any solution to compare them?