public class Test {

  public static void main(String[] args) {
int a = 10;
int b = 20;
int c = 25;
int d = 25;
System.out.println("a + b = " + (a + b) );
System.out.println("a - b = " + (a - b) );
System.out.println("a * b = " + (a * b) );
System.out.println("b / a = " + (b / a) );
System.out.println("b % a = " + (b % a) );
System.out.println("c % a = " + (c % a) );
System.out.println("a++ = " + (a++) );
System.out.println("a-- = " + (a--) );
// 查看 d++ 与 ++d 的不同
System.out.println("d++ = " + (d++) );
System.out.println("++d = " + (++d) );
}
}

public class selfAddMinus{
public static void main(String[] args){
int a = 3;//定义一个变量;
int b = ++a;//自增运算
int c = 3;
int d = --c;//自减运算
System.out.println("进行自增运算后的值等于"+b);
System.out.println("进行自减运算后的值等于"+d);
}
}
public class selfAddMinus{
public static void main(String[] args){
int a = 5;//定义一个变量;
int b = 5;
int x = 2*++a;
int y = 2*b++;
System.out.println("自增运算符前缀运算后a="+a+",x="+x);
System.out.println("自增运算符后缀运算后b="+b+",y="+y);
}
}

public class Test {

  public static void main(String[] args) {
int a = 10;
int b = 20;
System.out.println("a == b = " + (a == b) );
System.out.println("a != b = " + (a != b) );
System.out.println("a > b = " + (a > b) );
System.out.println("a < b = " + (a < b) );
System.out.println("b >= a = " + (b >= a) );
System.out.println("b <= a = " + (b <= a) );
}
}

public class Test {
public static void main(String[] args) {
int a = 60; /* 60 = 0011 1100 */
int b = 13; /* 13 = 0000 1101 */
int c = 0;
c = a & b; /* 12 = 0000 1100 */
System.out.println("a & b = " + c ); c = a | b; /* 61 = 0011 1101 */
System.out.println("a | b = " + c ); c = a ^ b; /* 49 = 0011 0001 */
System.out.println("a ^ b = " + c ); c = ~a; /*-61 = 1100 0011 */
System.out.println("~a = " + c ); c = a << 2; /* 240 = 1111 0000 */
System.out.println("a << 2 = " + c ); c = a >> 2; /* 15 = 1111 */
System.out.println("a >> 2 = " + c ); c = a >>> 2; /* 15 = 0000 1111 */
System.out.println("a >>> 2 = " + c );
}
}

public class Test {
public static void main(String[] args) {
boolean a = true;
boolean b = false;
System.out.println("a && b = " + (a&&b));
System.out.println("a || b = " + (a||b) );
System.out.println("!(a && b) = " + !(a && b));
}
}

public class LuoJi{
public static void main(String[] args){
int a = 5;//定义一个变量;
boolean b = (a<4)&&(a++<10);
System.out.println("使用短路逻辑运算符的结果为"+b);
System.out.println("a的结果为"+a);
}
}

public class Test {
public static void main(String[] args) {
int a = 10;
int b = 20;
int c = 0;
c = a + b;
System.out.println("c = a + b = " + c );
c += a ;
System.out.println("c += a = " + c );
c -= a ;
System.out.println("c -= a = " + c );
c *= a ;
System.out.println("c *= a = " + c );
a = 10;
c = 15;
c /= a ;
System.out.println("c /= a = " + c );
a = 10;
c = 15;
c %= a ;
System.out.println("c %= a = " + c );
c <<= 2 ;
System.out.println("c <<= 2 = " + c );
c >>= 2 ;
System.out.println("c >>= 2 = " + c );
c >>= 2 ;
System.out.println("c >>= 2 = " + c );
c &= a ;
System.out.println("c &= a = " + c );
c ^= a ;
System.out.println("c ^= a = " + c );
c |= a ;
System.out.println("c |= a = " + c );
}
}

public class Test {
public static void main(String[] args){
int a , b;
a = 10;
// 如果 a 等于 1 成立,则设置 b 为 20,否则为 30
b = (a == 1) ? 20 : 30;
System.out.println( "Value of b is : " + b ); // 如果 a 等于 10 成立,则设置 b 为 20,否则为 30
b = (a == 10) ? 20 : 30;
System.out.println( "Value of b is : " + b );
}
}

吴裕雄--天生自然 JAVA开发学习:运算符的更多相关文章

  1. 吴裕雄--天生自然 JAVA开发学习:变量类型

    public class Variable{ static int allClicks=0; // 类变量 String str="hello world"; // 实例变量 pu ...

  2. 吴裕雄--天生自然 JAVA开发学习:java使用Eclipel连接数据库

    1:jar可到Mysql官网下载:地址Mysql 连接jar包.:https://dev.mysql.com/downloads/connector/j/如图,在下拉列表框中选择Platform In ...

  3. 吴裕雄--天生自然 JAVA开发学习:解决java.sql.SQLException: The server time zone value报错

    这个异常是时区的错误,因此只你需要设置为你当前系统时区即可,解决方案如下: import java.sql.Connection ; import java.sql.DriverManager ; i ...

  4. 吴裕雄--天生自然 JAVA开发学习:基础语法

    package test; public class temp { /* 第一个Java程序 * 它将打印字符串 Hello World */ public static void main(Stri ...

  5. 吴裕雄--天生自然 JAVA开发学习:Scanner 类

    import java.util.Scanner; public class ScannerDemo { public static void main(String[] args) { Scanne ...

  6. 吴裕雄--天生自然 JAVA开发学习:流(Stream)、文件(File)和IO

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //使用 BufferedReader 在控制台读取 ...

  7. 吴裕雄--天生自然 JAVA开发学习:方法

    /** 返回两个整型变量数据的较大值 */ public static int max(int num1, int num2) { int result; if (num1 > num2) re ...

  8. 吴裕雄--天生自然 JAVA开发学习:正则表达式

    import java.util.regex.*; class RegexExample1{ public static void main(String args[]){ String conten ...

  9. 吴裕雄--天生自然 JAVA开发学习:日期时间

    import java.util.Date; public class DateDemo { public static void main(String args[]) { // 初始化 Date ...

随机推荐

  1. 7.Python列表

    .button, #logout { color: #333; background-color: #fff; border-color: #ccc; } span#login_widget > ...

  2. 一百一十一、SAP的OO-ALV之五,显示ALV表格

    一.在屏幕里面有2部分,(PROCESS BEFORE OUTPUT 用于显示, PROCESS AFTER INPUT用于数据处理).我们创建的display_alv函数, 二.display_al ...

  3. C#使用throw和throw ex的区别(转)

    使用throw和throw ex的区别 之前,在使用异常捕获语句try...catch...throw语句时,一直没太留意几种用法的区别,前几天调试程序时无意中了解到几种使用方法是有区别的,网上一查, ...

  4. APIO 2010 特别行动队 斜率优化DP

    Description 你有一支由 n 名预备役士兵组成的部队,士兵从 1 到 n 编号,要将他们拆分 成若干特别行动队调入战场.出于默契的考虑,同一支特别行动队中队员的编号 应该连续,即为形如 (i ...

  5. 洛谷 P2747 Canada Tour 周游加拿大 动态规划

    Description 你赢得了一场航空公司举办的比赛,奖品是一张加拿大机票.旅行在这家航空公司开放的最西边的城市开始,然后一直自西向东旅行,直到你到达最东边的城市,再由东向西返回,直到你回到开始的城 ...

  6. vs code 切换语言(切换回英文)

    安装中文 安装教程:https://www.cnblogs.com/chenxi188/protected/p/11757456.html 切换回英文 调出搜索:ctrl+shift+p 输入:lan ...

  7. Docker Ubuntu 例子

    版权所有,未经许可,禁止转载 章节 Docker 介绍 Docker 和虚拟机的区别 Docker 安装 Docker Hub Docker 镜像(image) Docker 容器(container ...

  8. spring boot 实战教程

    二八法则 - get more with less Java.spring经过多年的发展,各种技术纷繁芜杂,初学者往往不知道该从何下手.其实开发技术的世界也符合二八法则,80%的场景中只有20%的技术 ...

  9. java课程课后作业190530之用户体验评价

    每个人评价一下大家手头正在使用输入法或者搜索类的软件产品. 从用户界面.记住用户选择.短期刺激.长期使用的好处坏处.不要让用户犯简单的错误四个方面发表一篇博客. 输入法:苹果自带的输入法 用户界面:简 ...

  10. 简单makefile示例

    Makefile cmd: - g++ 相信在linux下编程的没有不知道makefile的,刚开始学习linux平台下的东西,了解了下makefile的制作,觉得有点东西可以记录下. 下面是一个极其 ...