I got the logic but I din't understood that why we are returning new String(password), is it converting the char[] to string, if so, how? I am always confused in casting and converting. Give me simple and detailed answer to understand the concept clearer.
private String randomPass(int length)
    {
        String passwordSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890@#";
        char[] password = new char[length];
        for(int i = 0; i < length; i++)
        {
            int rand = (int) (Math.random() * passwordSet.length());
            password[i] = passwordSet.charAt(rand);
        }
        return new String (password);
    }
 
    