青县网站建设,网站域名正在维护中,海南在线新闻中心海南一家,合肥小程序开发公司1、使用方法
//step1、实例化Scanner类
Scanner SC new Scanner(System.in);
//step2、进行java.util.Scanner的导包
//step3、进行提醒性的文字输出
System.out.println(“请输... “)#xff1b;
//step4、根据你的业务来判断你需要获取到输入信息的类型
sc.nextInt();
s…1、使用方法
//step1、实例化Scanner类
Scanner SC new Scanner(System.in);
//step2、进行java.util.Scanner的导包
//step3、进行提醒性的文字输出
System.out.println(“请输... “)
//step4、根据你的业务来判断你需要获取到输入信息的类型
sc.nextInt();
sc.next();
sc.nextDouble();
//step5、输入赋值给变量进行具体的业务逻辑操作2、字符转换demo
import java.util.Scanner;/*** author franklin* 通过Scanner来输入- -串字符然后把里面的大写转为小写小写转为大写数字保持不变* 进阶:再统计里面大写、小写、数字的个数* 1、需要有一个Scanner对 象* 2、接收的对象是-一个字符串;* 3、大写和小写是否存在某些规律可以让我们大写和小写进行转换;* 4、如何把-一串字符中的每- 一个字符给取出来* a、对字符串进行for循环;* b、拿到每-一个字符 charAt(index )*/
public class ScannerWork {public static void main(String[] args) {/*for (int i 0; i 127; i) {System.out.print((char)i );}System.out.println();for (int i 97; i 9726; i) {System.out.print((char)i );}System.out.println();for (int i A; i A26; i) {System.out.print((char)i );}*///大小写转换demo//1、创建scanner对象Scanner inputnew Scanner(System.in);//2、提醒输入字母串System.out.println(请输入字母进行大小写转换);//3、获取输入的字母串String strinput.next();//4. 进行大小写转换// 对字符串进行循环for (int i 0; i str.length() ; i) {//读取每一个字符char cstr.charAt(i);//拿到字符之后根据大写小写的规律来判断是否在某个区间内即可if (cacz){System.out.print((char)(c-32));}else if (cAcZ){System.out.print((char)(c32));}else {System.out.print(c);}}}
}