字符密码怎么写java
1.用JAVA编写输入用户名和密码
import java.util.Scanner;
public class Test
{
public static void main(String []args)
{
String str1="青";
int num1=123;
Scanner scanner=new Scanner(System.in);
System.out.print("请输入名字:");
String str=scanner.next(); //获取字符串值
System.out.println("您输入的名字是:"+str);
if(str1==str)
{
System.out.println("对不起,你不是青2");
}
else
{
System.out.print("请输入密码:");
int num=scanner.nextInt(); //获取整数值
System.out.println("您输入的密码是:"+num);
if(num1==num)
{
System.out.println("欢迎你,青");
}
else
{
System.out.println("对不起,你不是青1");
}
}
}
}
2.java中如何输入一个字符
import java.util.*;
public class Test_01
{
public static void main(String[] args)throws Exception
{
System.out.println("请输入一个字符");
char c=(char)System.in.read();
System.out.println(c);
}
}
扩展资料:
还可以输入字符串,输入字符串的方法
import java.io.*;
public class Test
{
public static void main(String[] args) throws IOException
{
BufferedReader buf = new BufferedReader (new InputStreamReader(System.in));
BufferedWriter buff = new BufferedWriter(new FileWriter("abc.txt"));
String str = buf.readLine();
while(!str.equals("exit"))
{
buff.write(str);
buff.newLine();
str = buf.readLine();
}
buf.close();
buff.close();
}
}
3.Java 写一个输入密码的小程序
已完成,复制粘贴即可。
import java.util.Scanner; public class YuGiOh { private static void checkPass ( String password ) { String regp = ".*[A-Z].*"; String rego = ".*[a-z].*"; String regq = ".*\\d.*"; String regs = ".*[\\`\\-\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\_\\+\\=\\[\\{\\}\\]\\;\\:\\,\\.\\<\\>\\/\\?].*"; String regex = "^[a-zA-Z\\d\\`\\-\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\_\\+\\=\\[\\{\\}\\]\\;\\:\\,\\.\\<\\>\\/\\?]{6,}$"; String result = ""; if (password.length () < 6) { result += "\t\t-contain at least six characters. Your password is only " + password.length () + " characters long.\n"; } if (!password.matches (regp)) { result += "\t\t-contain at least one uppercase letter.\n"; } if (!password.matches (rego)) { result += "\t\t-contain at least one lowercase letter.\n"; } if (!password.matches (regq)) { result += "\t\t-contain at least one number.\n"; } if (!password.matches (regs)) { result += "\t\t-contain at least one of the following special characters: `!@#$%^&*()_+=[{}];:,.<>/?\n"; } else if (!password.matches (regex)) { result += "\t\t-not contain an invalid character. The valid special characters: `!@#$%^&*()_+=[{}];:,.<>/?\n"; } if (!"".equals (result)) { System.out.println ("Your password must:\n" + result); } else { System.out.println ("Your valid password is: " + password); } System.out.println (); } public static void main ( String[] args ) { Scanner scanner = new Scanner (System.in); while (true) { System.out.print ("Enter a valid password: "); String password = scanner.nextLine (); checkPass (password); } } }。
4.java中如何输入一个字符
晕,刚才回答了你的问题,题目没了……
实在不大想把代码重新再写一遍了。实际上很简单。Scanner 是可以用的。读进来的是字符串,比如说保存在 str。
str.charAt(0); 就是第一个字符。括号里的数字就是 index。把字符串就当数组看好了。
还有一个解决方案就直接用 char c = (char)new BufferedReader(new InputStreamReader(System.in)).read();
就可以读取你输入的第一个字符。
然后有了字符你就随便处理好了。比如可以用 switch 语句:
switch (c) {
case 'A':
// do something
case 'B':
// do something
}
---------------------------------------
你初学者,我就把代码再写一遍吧:
import java.io.*;
public class Demo {
public static void main (String args[]) {
char c = 0;
try {
c = (char)new BufferedReader(new InputStreamReader(System.in)).read();
} catch (IOException ioe) {
System.exit(0);
}
switch (c) {
case 'A':
System.out.println("It is A.");
break;
case 'B':
System.out.println("It is B.");
break;
}
}
}
5.java如何输入一个字符
import java.util.Scanner; //引入Scanner类该类封装了接收用户输入参数的一些操作
写方法体
public static void main(String[] arg)
{
Scanner input=new Scanner(System.in); //定义一个从系统缓存读取数据的对偶
String str=scanner.next(); //从缓存中读出数据
System.out.println(str);
}
字符密码怎么写
1. 密码不少于6位字符应该怎么写
大写 、小写、数字和符号
只要你的密码你包括了 大写、小写 、数字和符号就行 ,顺序可以颠调
1、密码:
密码是一种用来混淆的技术,使用者希望将正常的(可识别的)信息转变为无法识别的信息。但这种无法识别的信息部分是可以再加工并恢复和破解的。密码在中文里是“口令”(password)的通称。
2、引证:
1).特别编制的秘密电码。在约定的范围内使用,以区别于“明码”。《二十年目睹之怪现状》第九二回:“便亲自起了个一百多字的电稿,用他自己私家的密码译了出来,送到电局,打给他胞弟 惠禄 。”郭沫若《洪波曲》第十五章五:“不过我还可以保证,他们一定会把密码电报大大地改编过一道。”
2).引申指隐密的信息。王蒙《春之声》:“春天的旋律,生活的密码,这是非常珍贵的。
2. 字符组成的密码是什么
字符是字母和符号组成的密码,字符是字母和符号的统称。
字母:英文26个字母大小写,如果区分大小写就是52个字母,不区分就是26个,即A和a一样
符号:类似键盘上(@、#、&、!、;、‘、等等)都算在内。
扩展资料:
密码的分类
1、摩斯密码
最早的摩尔斯电码是一些表示数字的点和划。数字对应单词,需要查找一本代码表才能知道每个词对应的数。用一个电键可以敲击出点、划以及中间的停顿。
2、四方密码:是一种对称式加密法,由法国人Felix Delastelle(1840年–1902年)发明。 这种方法将字母两个一组,然后采用多字母替换密码。
3、希尔密码:是运用基本矩阵论原理的替换密码,由Lester S. Hill在1929年发明。
4、波雷费密码:是一种对称式密码,是首种双字母取代的加密法。
5、仿射密码:仿射密码是一种替换密码。它是一个字母对一个字母的。
参考资料来源:百度百科-密码
转载请注明出处育才学习网 » 字符密码怎么写8位数
育才学习网