当前位置:网站首页>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
边栏推荐
- 7-1 introduction to finance
- Applet - canvas drawing Poster
- Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer
- . net webapi access authorization mechanism and process design (header token + redis)
- MySQL query specifies that a row is sorted to the first row
- Super easy to use asynchronous export function of Excel
- TCP three handshakes and four waves
- Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
- Problem B: small challenge
- Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
猜你喜欢

Node configuration environment CMD does not take effect

Visual programming - Experiment 2

Supersocket is Use in net5 - concept
![Super easy to use [general excel import function]](/img/9b/ef18d1b92848976b5a141af5f239b5.jpg)
Super easy to use [general excel import function]

Seminar playback video: how to improve Jenkins' ability to become a real Devops platform

Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)

淺學一下I/O流和File類文件操作

Test questions and some space wars

打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针

超好用的Excel异步导出功能
随机推荐
Super easy to use [general excel import function]
Why is bi so important to enterprises?
Supersocket is Use in net5 - concept
JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
浅学一下I/O流和File类文件操作
7-1 introduction to finance
JS, bind the event for a label with input, and then bind the stand-alone event in the parent element. The event is executed twice and solved
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
you need to be root to perform this command
Using jsonserialize to realize data type conversion gracefully
Problem C: Hanoi Tower III
MySQL keyword group_ Concat, combined connection query
通过 zxing 生成二维码
Unity games and related interview questions
oracle 查询外键含有逗号分隔的数据
C interface
Applet - more than two pieces of folding and expansion logic
MySQL installation pit
PWA I'm here