Advertisement
Guest User

Untitled

a guest
Oct 26th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. class Whileloop
  2. {
  3. public static void main (String args[])
  4. {
  5. int i = 1;
  6. while (i <= 4)
  7. {
  8. System.out.print("n");
  9. int j = 1;
  10. while (j <= i)
  11. {
  12. System.out.print(j);
  13. j++;
  14. }
  15. i++;
  16. }
  17. }
  18. }
  19.  
  20. do{
  21. //do here
  22. }while(booleanExpression);
  23.  
  24. class Tester
  25. {
  26. public static void main (String args[]){
  27.  
  28. int i=1;
  29. do{ //block started with out checking condition
  30. System.out.print("n");
  31. int j=1;
  32. do { //inner loop starts
  33. System.out.print(j);
  34. j++;
  35. }while(j<=i); //condition check for inner loop
  36. i++;
  37. }while(i<=4); //condition check for outer loop
  38. }
  39. }
  40.  
  41. int i=1;
  42. do {
  43. System.out.print("n");
  44. int j=1;
  45.  
  46. do {
  47. System.out.print(j);
  48. j++;
  49. } while (j<=i);
  50.  
  51. i++;
  52. } while(i <= 4);
  53. }
  54.  
  55. while(condition)
  56. {
  57. //code
  58. }
  59.  
  60. do
  61. {
  62. //code
  63. }while(condition);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement