I am a newbie to Java, and as an exercise wanted to WAP a simple program to print required no. of \'*\' characters according to the user. But somehow, the output of this cod
no_stars = (int)System.in.read();
This is using the ASCII value of whatever character the user enters. Try this instead:
no_stars = System.in.read() - '0';
Or, remove the no_stars variable all together,
printstars(System.in.read() - '0');
Also, in your for-loop, the condition should be i < n, in order to perform the correct number of iterations. And there's no need to declare i outside of the loop, you can just do for (int i = 0; i < n; i++).