当前位置:网站首页>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
边栏推荐
- JS - accuracy issues
- Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
- Unity Basics
- POI create and export Excel based on data
- JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
- How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
- C-11 problem h: treasure chest 2
- Why is bi so important to enterprises?
- 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
- 12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
猜你喜欢
超好用的【通用Excel导入功能】
Visual programming - drawing assignment
Section 2 map and structure in Chapter 6
Redis(17) -- Redis缓存相关问题解决
New ORM framework -- Introduction to beetlsql
Using swagger in. Net5
Development record of primary sensitive word detection
MySQL keyword group_ Concat, combined connection query
L3-011 直捣黄龙 (30 分)
C set
随机推荐
socket编程 send()与 recv()函数详解
超好用的【通用Excel导入功能】
Unity basics 2
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
Visual programming - Experiment 1
Unity knowledge points (common core classes)
Supersocket is Use in net5 - startup
js 中,为一个里面带有input 的label 绑定事件后在父元素绑定单机事件,事件执行两次,求解
PYMOL-note
Codeforces Round #784 (Div. 4)題解 (第一次AK cf (XD
2022 团体程序设计天梯赛 模拟赛 L1-7 矩阵列平移 (20 分)
Iotos IOT middle platform is connected to the access control system of isecure center
Eight elder brothers chronicle [4]
L3-011 direct attack Huanglong (30 points)
poi根据数据创建导出excel
浅学一下I/O流和File类文件操作
The fourth operation
Téléchargement en vrac de fichiers - téléchargement après compression
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director