当前位置:网站首页>Type conversion, variable
Type conversion, variable
2022-07-03 17:20:00 【Onycho】
Type conversion
```public class Demo03 {
public static void main(String[] args) {
int i = 128;
//byte b = (byte) i; // out of memory
double b = i;
// Coercive transformation ( type ) Variable name High to low
// Automatic conversion Low to high
System.out.println(i);
System.out.println(b);
/* Be careful 1. Cannot convert Boolean values 2. You cannot convert an object type to an unrelated type 3. Force conversion when converting high capacity to low capacity 4. There may be memory overflow during conversion , Or accuracy issues */
System.out.println("=====================");
System.out.println((int)23.7); //23
System.out.println((int)-45.89f); //-45
System.out.println("=====================");
char c = 'a';
int d = c+1;
System.out.println(d);
System.out.println((char)d);
}
}
Output
128
128.0
=====================
23
-45
=====================
98
b
Variable
边栏推荐
- University of Electronic Science and technology, accounting computerization, spring 20 final exam [standard answer]
- 鸿蒙第四次培训
- Javescript variable declaration -- VaR, let, const
- AcWing 3438. Number system conversion
- [combinatorics] recursive equation (the problem of solving recursive equation with multiple roots | the problem is raised)
- PHP online confusion encryption tutorial sharing + basically no solution
- Stm32h7 Hal library SPI DMA transmission has been in busy solution
- C language string inversion
- Unity notes unityxr simple to use
- C语言字符串反转
猜你喜欢
PHP online confusion encryption tutorial sharing + basically no solution
Test your trained model
Hongmeng third training
QT adjust win screen brightness and sound size
Kubernetes resource object introduction and common commands (III)
Cross border e-commerce: advantages of foreign trade enterprises in overseas social media marketing
鸿蒙第四次培训
Design e-commerce spike
1164 Good in C
SWM32系列教程4-端口映射及串口应用
随机推荐
Atom QT 16_ audiorecorder
[combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
Solution to long waiting time of SSH connection to remote host
Thread pool: the most common and error prone component of business code
Examination questions for the assignment of selected readings of British and American Literature in the course examination of Fujian Normal University in February 2022
One brush 147-force deduction hot question-4 find the median of two positive arrays (H)
国内如何购买Google Colab会员
跨境电商:外贸企业做海外社媒营销的优势
Great changes! National housing prices fell below the 10000 yuan mark
kubernetes资源对象介绍及常用命令(五)-(NFS&PV&PVC)
Dagong 21 autumn "power plant electrical part" online operation 1 [standard answer] power plant electrical part
Apache service suspended asynchronous acceptex failed
Leetcode13. Roman numeral to integer (three solutions)
Select 3 fcpx plug-ins. Come and see if you like them
[combinatorics] recursive equation (the problem of solving recursive equation with multiple roots | the problem is raised)
[combinatorics] recursive equation (solution of linear non-homogeneous recursive equation with constant coefficients | standard form and general solution of recursive equation | proof of general solut
Take you to API development by hand
定义一个结构体Fraction,表示分数,用于表示 2/3, 5/6这样的分数
人生还在迷茫?也许这些订阅号里有你需要的答案!
Svn full backup svnadmin hotcopy