You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
409 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

public class Jb03_VarDemo2
{
public static void main(String[] args)
{
/*
int x = 1;
x = x + 1;
byte b = 2;
x = x + b; //自动类型转换
b = (byte)(b + 2); //强制类型转换
System.out.println(b);
*/
byte b = 1;
byte b1 = 2;
byte b2 = 3;
// b = b1 + b2; b1与b2是变量无法判断并赋值
int x;
int x1 = Integer.MAX_VALUE;
int x2 = 2;
x = x1 + x2; //int是默认类型自动强制转换
}
}