Otp.java
package java8s;
import
java.util.Random;
public class Otp {
static char[] sendOtp(int length){
System.out.println("your otp
for this transaction is:");
String
numbers="0123456789";
Random
r=new Random();
char[] otp=new char[length];
for(int i=0;i<length;i++)
{
otp[i]=numbers.charAt(r.nextInt(numbers.length()));
}
return otp;
}
public static void main(String[] args) {
System.out.println("generating
otp....");
System.out.println(sendOtp(4));
}
}
Output
generating otp....
your otp for this transaction is:
7176
No comments:
Post a Comment