当前位置:网站首页>Commonly used classes
Commonly used classes
2022-04-23 03:29:00 【Aiyou coffee】
Packaging : A wrapper class encapsulates a basic type into a class that contains properties and methods , Convenient object operation .( The packaging class is located in Java.lang In bag )
Packaging class and data class, idiomatic class 1. The basic data type is converted to a wrapper class 2. Convert wrapper class to base type 3. Automatic conversion of basic data and packaging class ( Wrapper classes are not intended to replace basic types )
Automatic packing and unpacking (auto-baxing&unboxing)
Automatic boxing : The basic data type is automatically encapsulated in a wrapper of the same type , Such as :Integer i= 100;
It's essentially time for us to add the compiler :Inter i = Integer.valueOf(100);
Automatic dismantling : Wrapper class objects are automatically converted to basic data types , Such as :int a = new Integer(100);
Essentially, , When compiling, the compiler adds :int a = new Intrger(100).intValue();
{1. Boxing and UnBoxing , Packing : basic --> class new Interger(int)---->new Integer.valueOf(int i)
Unpacking : class ---> basic intValue()
2. Method And string conversion method
(a) character string --->Integer Interger(String s) Integer.parsenInt(Strng s ) Integer.valueOf(String s)
(b)Integer---> character string toString() String.valueOf(Object obj) Interger---->int +""}
String( Immutable character sequence ) Java String is Unicode Character sequence , for example Java There are four Unicode character string J,a,v,a form Java Symbols are allowed "+" Connect two strings .
String Common methods of class
char charAt(int indx) Returns the second... In the string index Characters
boolean equals(String other) If the string and other equal ( Ignore case ), Then return to true
Practice on the computer
use String The use of the class , Definition and use of methods with parameters – Realize member registration , The length of user name is required to be no less than 3, The password length is not less than 6, Twice during registration The password entered must be the same
public class Register {
public static void main(String[] args) {
Scanner cz = new Scanner(System.in);
System.out.println(" Welcome to the member registration system :");
boolean flag = true;
while(flag){
System.out.println(" Please enter a user name ");
String name = cz.next();
System.out.println(" Please input a password ");
String pwd = cz.next();
System.out.println(" Please input the password again ");
String pwd1 = cz.next();
if(name.length()<3||pwd.length()<6){
System.out.println(" The user name length is less than 3 Or the password length is less than 6");
}else if(!pwd.equals(pwd1)){
System.out.println(" The two passwords are different ");
}else if(name.length()>=3&&pwd.length()>=6&&pwd.equals(pwd1)){
System.out.println(" Registered successfully ! Please remember the user name and password ");
break;
}
}
}
}
版权声明
本文为[Aiyou coffee]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619008822.html
边栏推荐
- MySQL之explain关键字详解
- Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
- Query stored procedures in PostgreSQL
- The query type of MySQL is very inefficient.
- QT uses drag and drop picture to control and mouse to move picture
- 场景题:A系统如何使用B系统的页面
- 2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)
- Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
- ThreadLocal test multithreaded variable instance
- Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
猜你喜欢
Section 2 map and structure in Chapter 6
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
2022 团体程序设计天梯赛 模拟赛 L1-7 矩阵列平移 (20 分)
Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
Visual programming - drawing assignment
AWS from entry to actual combat: creating accounts
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
Redis (17) -- redis cache related problem solving
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
随机推荐
Codeforces Round #784 (Div. 4)题解 (第一次AK cf (XD
Idea view history [file history and project history]
TCP three handshakes and four waves
C set
Using jsonserialize to realize data type conversion gracefully
Applet - canvas drawing Poster
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
Quartz. Www. 18fu Used in net core
Codeforces round 784 (Div. 4) (AK CF (XD) for the first time)
"Visual programming" test paper
Build websocket server in. Net5 webapi
Basic use of Charles
Redis(17) -- Redis缓存相关问题解决
Query stored procedures in PostgreSQL
socket编程 send()与 recv()函数详解
集合之List接口
Log4net is in Net core usage
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
C interface
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)