Test01.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package com.sf.day01;
  2. import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
  3. import java.sql.SQLOutput;
  4. /**
  5. * 1 - 在day01包下创建一个类 类名Test01
  6. * 2 - 当前类 class
  7. * 3 - public 公共的 公开的 - 权限修饰符中的一种
  8. * 4 - Student 标识符
  9. * 标识符和关键字不同 :
  10. * 关键字 - Java给我们定义好的 我们不能用关键字作为标识符
  11. * 标识符: 凡是自己起名字的都可以称之为标识符
  12. * 见名知意 - 好记 getInfo() updateUserByUserId(); -- yVoid
  13. * com.sf.day01 包名 通常 包名定义 : 公司域名的倒叙
  14. * www.baidu.com -- 域名 196.168.xx.xx ip
  15. * 47.96.190.116 -- www.guyanqing.com
  16. * Student 类名
  17. */
  18. public class Test01 {
  19. String name = "zhangdan";
  20. public static void main(String[] args) {
  21. int a = 1; //初始化
  22. // System.out.println(a);
  23. a = 2;
  24. System.out.println(a);
  25. int b ; //声明
  26. b = 18; //赋值
  27. System.out.println(b);
  28. int d = 20;
  29. int e = 0; //没有赋值 int 的默认值是 0
  30. System.out.println(d);
  31. System.out.println(e);
  32. System.out.println("===============================");
  33. /**
  34. * 基本数据类型
  35. * byte short int long 整型
  36. * float double 浮点类型
  37. * char 字符类型
  38. * Boolean 布尔类型 true false
  39. * 规范 long L
  40. */
  41. byte aa = 1;
  42. short bb = 2;
  43. int cc = 3;
  44. long dd = 4L;
  45. /**
  46. * 浮点数据类型
  47. */
  48. float ee = 5.0F;
  49. /*
  50. double Double的区别:
  51. int 0 double 0.0
  52. Double 默认值 null
  53. 选择: 用double作为一个接受的变量(非0.0) double/Double
  54. 映射实体的时候 Double 默认值 null
  55. eg:
  56. double aa = 0.0; aa = 0.0;
  57. int bb ;
  58. bb = 1; 1
  59. sout bb ; // 0
  60. Double / Integer null 0;
  61. */
  62. double ff = 6.0D; //基本数据类型
  63. Double gg = 7.0D; //类 double的包装类 自动拆装箱
  64. char hh = 'A'; //A 65 a 97
  65. String jj = "AA";
  66. int qq = 1;
  67. char ww = 'A'; //65
  68. System.out.println(ww+qq);
  69. char qqq = (char) (66);
  70. System.out.println(qqq);
  71. boolean rr = true;
  72. boolean yy = false;
  73. // ctrl + d
  74. int zz = 5;
  75. float zzz = 5; //5 int float
  76. long ll = 112;
  77. // 小转大 自动转换
  78. ll = zz;
  79. // 大转小 强转
  80. zz = (int) ll;
  81. }
  82. }