• java 运算符表达式


    1. /*
    2. * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
    3. *
    4. */
    5. package cn.webrx;
    6. /**
    7. *

    8. *

      Powered by webrx On 2023-02-07 17:23:31

    9. *
    10. * @author webrx [webrx@126.com]
    11. * @version 1.0
    12. * @since 17
    13. */
    14. public class Op1 {
    15. public static void main(String[] args) {
    16. //++ --
    17. double d = 1.56;
    18. System.out.println(++d);//先++运行,再使用 2.56
    19. System.out.println(d++);//先使用,再身++ 2.56
    20. System.out.println(d);//3.56
    21. int a = 3; //a = 3
    22. int b = ++a;// b =4 a=4
    23. System.out.println(b--);//4 b=3
    24. System.out.println(b);//3
    25. //程序在些行结束
    26. //System.exit(0);
    27. System.out.println("-------------------------------------------");
    28. //+
    29. System.out.println(+3);
    30. System.out.println(3);
    31. System.out.println(3 + 2);
    32. System.out.println("hello:" + "李四");
    33. //输出快捷键 psvm sout
    34. System.out.println("hello" + 8);
    35. //-
    36. System.out.println(2 - 3);
    37. System.out.println(-3);
    38. //*
    39. System.out.println(2 * 3);
    40. System.out.println("*".repeat(10));
    41. // / 求整商数 %取余
    42. System.out.println(5 / 2);//2
    43. System.out.println(5 % 2);//1
    44. System.out.println(1.0 * 5 / 2);//2.5
    45. //3.33
    46. System.out.printf("%.2f%n", 1.0 * 10 / 3);
    47. //3.59
    48. System.out.printf("%.2f%n", 3.586);
    49. }
    50. }
    51. 求整商余数案例
    52. /*
    53. * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
    54. *
    55. */
    56. package cn.webrx;
    57. /**
    58. *

    59. *
    60. * @since 17
    61. */
    62. public class Ex01 {
    63. public static void main(String[] args) {
    64. int a = 10;
    65. int b = 2;
    66. a = Integer.parseInt(args[0]);
    67. b = Integer.parseInt(args[1]);
    68. //÷×+-
    69. if (a % b == 0) {
    70. System.out.printf("%d ÷ %d = %d%n", a, b, a / b);
    71. } else {
    72. System.out.printf("%d ÷ %d = %d ... %d%n", a, b, a / b, a % b);
    73. }
    74. }
    75. }

  • 相关阅读:
    tauri 开发
    VMware与CentOS8-stream的配置教程【2022-9-5】
    Android 11判断应用已安装坑点
    nRF5340(入门篇)之1.1 nrf5340芯片简介
    React Refs 使用场景及核心要点
    测试工程师的简历到底怎么写?
    postgres字符串转数字
    chrome extension无法获取window对象
    MySQL高阶---存储引擎、索引、锁
    springboot在filter中设置跨域
  • 原文地址:https://blog.csdn.net/webxscan/article/details/133776898