//: AllOps.java
// Tests all the operators on all the
// primitive data types to show which
// ones are accepted by the Java compiler.
class AllOps {
// To accept the results of a boolean test:
void f(boolean b) {}
void boolTest(boolean x, boolean y) {
// Arithmetic operators:
//! x = x * y;
//! x = x / y;
//! x = x % y;
//! x = x + y;
//! x = x - y;
//! x++;
//! x--;
//! x = +y;
//! x = -y;
// Relational and logical:
//! f(x > y);
//! f(x >= y);
//! f(x < y);
//! f(x <= y);
f(x == y);作者: shi0000 时间: 2014-4-4 21:59
int型+int等型时是运算符,当int等型+String型时会把后者改为int型,String+String时才是字符串连接。这是程序默认的。作者: love~陌 时间: 2014-4-5 10:31
帅锅,+(这个东西)在Java中只有三种用途:
相加
正号(即表示正数)
实现字符串相连