that is expected output is

sun   mon   tue  wed  thu  fri  sat
                       1    2    3
4      5     6    7     8   9    10
29  30  31

my code:

static void print_31days(int a[][]){
	int i=1;
		int some=0;//some is the startdate of the month of the 
		while( some<5){
		for(int k=0;k<5&&i<=31;k++){//k is the number of weeks
		for(int j =1;j%8!=0&&i<=31;j++){//j is the number of days

output wat i got is this

enter month
enter the number of the month
month is jan\
number of month is 1

sun	mon	tue	wed	thur	fri	sat	
sat 	sun 	mon 	tue 	wed 	thu 	fri 	
---	---	---	---	---	1	2	
3	4	5	6	7	
8	9	
10	11	12	13	14	
15	16	
17	18	19	20	21	
22	23	
24	25	26	27	28	
29	30	

try k less than most likely won't work perfectly, but it will give you a hint. tell us what does your int[][] a parameter to the method hold. it's dimensions. besides, you could reach the effect with a one-dimensional array as well...

nope its nt workin with k<7.

for(int j =1;j%8!=0 ...
why not just
for(int j =1;j<8 ...

looks very wrong, and is why you are getting extra line breaks. Remove it and the formatting is OK apart from the very first line. I suspect the mystery thing you are doing with "some" at the start is to do with getting the first line offset right, so you probably need to use this to get the first line printed OK

well, remove lines 22 to 24 first. you do not need that if just yet. then see what .you get, perhaps that will direct you.

and why don't use java.util.Calendar or Date (and only hard code Month + Year for expected and correct output)

no i wanted to implement on my own ,was stuck in the middle so thought of getting help from techies.
thanks guys i got it.