import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
      Scanner sc= new Scanner (System.in);
        System.out.println("repeat a number");
         int n =5;
        int rep; 
        int a = 8;
        while (0<a)
    {
        System.out.println(n);
        rep = 0+a;
        a--;
        if (a==rep)
        break;
}
      
         
   // repeat using for loop
     
     System.out.println("using for loop");
     int b ;
     int c =5;
     for (b=8;0<c; c--)
   {  System.out.println(b);
   }
   
   
   //Print a number 1 to n
     System.out.println("print a number 1 to n");
    int a1 = 1;
    int n1 = 6;
    for (a1=1; n1>=a1; a1++)
   { 
       System.out.println(a1);
   
   }  
       
     
  // reverse a numbers
  System.out.println("reverse a numbers");
 String n2 = "ghhghhhhf";
 int a2 =1;
 int l =n2.length();
  System.out.println(l);
 
 
 for ( a2=1;a2<l ; )  
{ --l;
    System.out.print(n2.charAt(l));
  // System.out.println(l);
   
 if (l==1)
 break;
}
 
 
 
 
 
 
 
 
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: