Sunday, October 28, 2012

A Trick which help every new Java programmer and also "FOR" loop program for decrements of numbers, inside this post !!!!!



Hey guys, this time I want to tell you one short key so that you don't have to write down full line for example write down the "syso" and  press Ctrl + Spacebar, now tell me what you got. Of course "System.out.println();" and you can use same keys for other keywords. You don't need to writedown all words, just write starting words and press this keys then you got what you want. Isn't that cool ???? I hope this small trick help you a lot till you become professional Java programmer that is for lifetime.

Now in this post I just present small program of number decrements. And here it is.

________________________________________________


public class SimpleFor {

public static void main(String[]args){

for(int x=1; x<=21; x++){

for(int y = 1; y<=x;y++){

//System.out.print(" ");


System.out.print(x);
}

System.out.println(" ");
}
}

}
________________________________________________________________

OUTPUT:

22 
333 
4444 
55555 
666666 
7777777 
88888888 
999999999 
10101010101010101010 
1111111111111111111111 
121212121212121212121212 
13131313131313131313131313 
1414141414141414141414141414 
151515151515151515151515151515 
16161616161616161616161616161616 
1717171717171717171717171717171717 
181818181818181818181818181818181818 
19191919191919191919191919191919191919 
2020202020202020202020202020202020202020 
212121212121212121212121212121212121212121 


Now if you remove that "//" from "syso" from the above code, you know what I mean, then you got following output:




 1 
 2 2 
 3 3 3 
 4 4 4 4 
 5 5 5 5 5 
 6 6 6 6 6 6 
 7 7 7 7 7 7 7 
 8 8 8 8 8 8 8 8 
 9 9 9 9 9 9 9 9 9 
 10 10 10 10 10 10 10 10 10 10 
 11 11 11 11 11 11 11 11 11 11 11 
 12 12 12 12 12 12 12 12 12 12 12 12 
 13 13 13 13 13 13 13 13 13 13 13 13 13 
 14 14 14 14 14 14 14 14 14 14 14 14 14 14 
 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 
 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 
 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 
 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 
 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 
 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 
 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 

Now you can see the difference that is space matters a lot. Right guys???

No comments:

Post a Comment