主要介绍运算符,和数学函数以及三元运算符: package testbotoo; public class test1 { public static void main(String[] args) { int a = 122; System.out.println("调用operation的结果是:"+operation(a)); //调用下面定义的方法 }; public static int operation(int v){ int xe = v + 1; int and =…
类型检查 Java的任意变量和引用经过类型声明(type declaration),才能使用.我们之前见过对象数据.类数据.方法参数.方法返回值以及方法内部的自动变量,它们都需要声明其类型.Java是一种强类型(strongly typing)语言,它会对类型进行检查.如果我们错误的使用类型,将造成错误. 比如在下面的Test类中,我们将一个Cup类对象赋予给aPerson类引用: public class Test{ public static void main(String[] ar…