From Chartreuse Capybara, 1 Year ago, written in FreeSWITCH.
- view diff
Embed
  1. import java.util.Random;
  2.  
  3. public class IndianPhoneNumberGenerator {
  4.     public static void main(String[] args) {
  5.         // Define a method to generate a random Indian phone number
  6.         String phoneNumber = generateRandomIndianPhoneNumber();
  7.        
  8.         // Print the generated phone number
  9.         System.out.println("Random Indian Phone Number: " + phoneNumber);
  10.     }
  11.    
  12.     public static String generateRandomIndianPhoneNumber() {
  13.         Random rand = new Random();
  14.        
  15.         // Indian phone numbers typically start with 7, 8, or 9, followed by 9 digits.
  16.         // For example, 9876543210.
  17.        
  18.         // Generate the first digit (7, 8, or 9)
  19.         int firstDigit = rand.nextInt(3) + 7;
  20.        
  21.         // Generate the remaining 9 digits
  22.         StringBuilder phoneNumber = new StringBuilder(String.valueOf(firstDigit));
  23.         for (int i = 1; i < 10; i++) {
  24.             phoneNumber.append(rand.nextInt(10));
  25.         }
  26.        
  27.         return phoneNumber.toString();
  28.     }
  29. }
  30.