Aniket The Programmer
1.22K+ Subscribers
Click To Subscribe My Channel
import java.util.Scanner; import java.util.Random; class main{ static void password(int length){ String word = "abcdefghijklmnopqrstuvwxyz1234567890!@#$^&*"; char passChar[] = word.toCharArray(); char result[] = new char[length]; Random random = new Random(); for(int i = 0 ; i < length ; i++){ result[i] = passChar[random.nextInt(word.length())]; System.out.print(result[i]); } System.out.println("\n"); } public static void main(String arg[]){ System.out.println("Random Password Generator....."); Scanner sc = new Scanner(System.in); System.out.println("Enter length of password...."); int passLength = sc.nextInt(); password(passLength); } }
Source Code Github Link: View
View Video On Youtube Link: View
Prev
Random Password Generator in cpp language
Next
Random Password Generator in python language
35k+ Coding Problems: DSA Problem website is collection of 35k+ coding problems Click Here To Visit Website! 🎉