Java 2017.9.18 杨浩宁作业
public class Test { public static void main(String[] args){ //输出一个长整型的变量 123456789012345 long h = 123456789012345l; System.out.println(h); //输出一个单精度的小数常量 2.4 float h1 = 2.4f; System.out.println(h1); //输出布尔类型的变量 boolean h2 = true; System.out.println(h2); h2 = false; System.out.println(h2); // byte h3 = 3; h3 = (byte)(h3 + 200); System.out.println(h3); //输出字符型的加法计算 System.out.println((char)('a' + 1)); System.out.println((char)('我' + 1)); //演示变量的溢出效果 int h4 = integer.MAX_VALUE + 1; System.out.println(h4); //给x赋值,进行x=x/1000*1000的计算并输出结果 /* * import java.util.Scanner; public class Math{ public static void main(String[] args) { Scanner input=new Scanner(System.in); double x; System.out.println("Enter the x "); x = Double.valueOf(input.nextDouble()); x = x / 1000 * 1000; System.out.println("The calculation result is " + x); } * */ } }