生成大写和小写字母

时间:2014-10-17 04:40:45

标签: java char

我遇到了类,接口或枚举错误以及非法的表达式启动。我怎样才能解决这个问题?代码应该生成一个包含大写和小写字母的密码。它还需要检测输入的字母是大写还是小写。

// Returns a random Capital letter as a char
 static private char GenerateCapitalLetter() 
 {
    char returnChar = 'A';

    
    // Write your code here
    // HINT: look at the GenerateNumber() method
    // HINT: think of how to modify GenerateNumber() to generate a Capital letter

	{

    Random random = new Random();
    random.ints(65, 90).limit(10)
    		{
            .forEach(a -> System.out.println(Character.toString((char) a)));
            }
    	}
	}
}

 
 
 // Generate lowercase letter

static private char GenerateCapitalLetter()
{
	char returnChar = 'a';
	{

    Random random = new Random();
    random.ints(97, 126).limit(10)
    		{
            .forEach(a -> System.out.println(Character.toString((char) a)));
            }
   		}
	}
}





 // Tests to see if an input char is a Capital letter in code below

 
 // Tests to see if an input char is a lowercase letter     
char input=' ';
{
    if (Character.isLowerCase(input) || Character.isUpperCase(input))
    	{
        if (Character.isLowerCase(input))
            System.out.println("lower");
        } else {
            System.out.println("upper");
        }
    }
}

0 个答案:

没有答案