当前位置:网站首页>Identifier and type conversion
Identifier and type conversion
2022-04-23 03:28:00 【Aiyou coffee】
identifier
Definition : It's for the class , Method , Variables and other named symbols .
The rules :1. It's numbers , Letter , Dollar sign and underline (—) form .
2. Cannot start with a number
3. Cannot be keyword
4. Be case sensitive
Common naming rules :
Naming of small hump : Mainly for methods and variables
1. When the identifier is a word , title case .
2. When an identifier consists of multiple words , First word initial lowercase , Capitalize other words .
The name of the great hump : Mainly for class
1. When the identifier is a word , title case .
2. When an identifier consists of multiple words , Capitalize each word .
See the name and know the meaning
Type conversion
classification : Automatic conversion , Coercive transformation
Data types are small to large
char(16)
byte(8)-----short(16)-----int(32)-----long(64)-----float(32)-----double(64)
among char Convert directly to int type , Cannot be converted to byte and short type .
Don't forget int Type can be directly converted to double type .
Automatic conversion type : Assign a value or variable that represents a small range of data to another variable that represents a large range of data .
Automatic conversion type is low-level and can be directly converted to high-level
public class change{
public static void main(String[]args){
int a = 10:;
System.out.println(a);
double b =10;
System.out.println(b);
// among a The output number will be 10, however b The output is 10.0
// This is it. int Type is automatically converted to double
}
}
In fact, you can also experiment byte turn short This automatic conversion .
remember byte and short Cannot convert to char Type of yo .
Coercive transformation : Assign a data or variable representing a large data range to another variable representing a small data range .
Format : Target data type Variable name = ( Target data type ) Values or variables
Public class change{
public static void main (String []args){
// Define a double The number of types is strongly changed to int type
//int c = 66.66;
// System.out.println(c);
// If it is written in this way, it will show incompatibility, so it is wrong and should be forced to
int a = (int)66.66;
System.out.println(a);
}
}
The above code error has been shielded , The following strong rotation can be run .
But the one bad thing about forced conversion is that there will be data loss . Just like up here 66.66 Convert to int After the type, there is only 66 了 .
版权声明
本文为[Aiyou coffee]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619009330.html
边栏推荐
- MySQL keyword group_ Concat, combined connection query
- 2022 group programming ladder simulation match 1-8 are prime numbers (20 points)
- Seminar playback video: how to improve Jenkins' ability to become a real Devops platform
- MySQL query specifies that a row is sorted to the first row
- Unity knowledge points (ugui 2)
- MySQL installation pit
- C-11 problem I: find balloon
- Quartz. Www. 18fu Used in net core
- String input problem
- Visual programming - drawing assignment
猜你喜欢

2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)

It can receive multiple data type parameters - variable parameters

Problem a: face recognition

Supersocket is Used in net5 - command

Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)

关于idea调试模式下启动特别慢的优化

超好用的Excel异步导出功能

Peut recevoir plusieurs paramètres de type de données - paramètres variables

移植tslib时ts_setup: No such file or directory、ts_open: No such file or director

Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
随机推荐
浅学一下I/O流和File类文件操作
Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
ThreadLocal 测试多线程变量实例
Cefsharp stores cookies and reads cookies
Problem C: Hanoi Tower III
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
Visual programming - Experiment 1
POI create and export Excel based on data
Téléchargement en vrac de fichiers - téléchargement après compression
. net 5 Web custom middleware implementation returns the default picture
QT dynamic translation of Chinese and English languages
Generate QR code through zxing
JS implementation of new
淺學一下I/O流和File類文件操作
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
第四次作业
Explanation keyword of MySQL
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
It can receive multiple data type parameters - variable parameters
L3-011 direct attack Huanglong (30 points)