guyanqing 11 сар өмнө
parent
commit
b2276100f1

+ 46 - 0
src/main/java/com/sf/Test2.java

@@ -0,0 +1,46 @@
+package com.sf;
+
+public class Test2 {
+    //程序启动的入口   main
+    public static void main(String[] args){
+        /**
+         *   数据类型  整型  byte short int long
+         *   `               1    2     4   8
+         *                   -128 ~ 127
+         *                   计算机最小的计算单元  bit   1字节 = 8bit
+         *  产品类型   5;
+         *  byte  a = 5;
+         *  int b = 5;
+         *
+         *  i++   ++i   区别
+         *  先赋值后运算  先运算后赋值
+         *  i++ 和 ++i 区别
+         *  无接受值: i++ 和 ++i  效果等同  都是进行自增一的操作
+         *  有接收值: i++ 满足 先赋值后运算    ++i 满足 先运算后赋值
+         *
+         *
+         *  &       && 区别   |  ||
+         *  逻辑与  短路与
+         *  true  &  false   -->  false
+         *  true  &&  false   -->  false
+         *
+         *  T  &  T/F  -->T/F  都走
+         *  T  &&  T/F  --> T/F
+         *  F  &&  T/F  --> F
+         */
+
+
+//        int a = 10;
+////       int c = a++;
+//          int c =  ++a;
+//        System.out.println(a);  //11
+//        System.out.println(c);
+        int x = 1;
+        int y = 1;
+        if (x++ == 2 && ++y == 2){
+            x = 7;
+        }
+        System.out.println(x);
+        System.out.println(y);
+    }
+}

+ 23 - 0
src/main/java/com/sf/day07_2/Animal.java

@@ -0,0 +1,23 @@
+package com.sf.day07_2;
+
+/**
+ * 小动物类
+ */
+public class Animal {
+    //属性
+   String name;
+   int age;
+   int sex;
+   double height;
+   double weight;
+   int  color; //1 red  2  yellow 3 pink
+
+    //行为
+    public void eat(String name){
+        System.out.println(name+"--eat...");
+        }
+
+    public void  run(){
+        System.out.println("run...");
+    }
+ }

+ 29 - 0
src/main/java/com/sf/day07_2/AnimalTest.java

@@ -0,0 +1,29 @@
+package com.sf.day07_2;
+
+import org.junit.Test;
+
+public class AnimalTest {
+    public static void main(String[] args) {
+        Animal animal = new Animal();
+        animal.name = "cat";
+        animal.age = 2;
+        animal.color = 1;
+        animal.height = 23.9;
+        animal.sex = 2;
+        animal.weight = 12.3;
+        animal.eat(animal.name);
+        System.out.println("身高"+animal.height);
+    }
+
+    @Test
+    public void t1(){
+        Animal animal = new Animal();
+        animal.name = "dog";
+        animal.age = 2;
+        animal.color = 1;
+        animal.height = 23.9;
+        animal.sex = 2;
+        animal.weight = 12.3;
+        animal.eat(animal.name);
+    }
+}

+ 47 - 0
src/main/java/com/sf/day07_2/Test.java

@@ -0,0 +1,47 @@
+package com.sf.day07_2;
+import java.util.Arrays;
+
+/**
+ *Arrays工具类的使用
+ */
+public class Test {
+    @org.junit.Test
+    public void t1(){
+
+        //toString
+        int[] arr = {2,3,4,5,6,7};
+        System.out.println(arr);
+        String arrStr = Arrays.toString(arr);
+        System.out.println(arrStr);
+    }
+
+    @org.junit.Test
+    public void t2(){
+        int[] arr = {3,2,5,1,7,9,4};
+//        Arrays.sort(arr);
+        Arrays.sort(arr,1,5);
+        System.out.println(Arrays.toString(arr));
+    }
+
+
+    @org.junit.Test
+    public void t3(){
+        int[] arr = {1,2,3,4,5,6,7,8,9};
+        int i = Arrays.binarySearch(arr, 10);
+        System.out.println(i);
+    }
+
+
+    @org.junit.Test
+    public void t4(){
+        int[] arr =  {1,2,3,4,5,6,7,8,9};
+//        int[] ints = Arrays.copyOf(arr, 8);
+//        System.out.println(Arrays.toString(ints));
+        int[] ints = Arrays.copyOfRange(arr, 1, 6);
+        System.out.println(Arrays.toString(ints));
+        boolean equals = Arrays.equals(arr, ints);
+        System.out.println(equals);
+        Arrays.fill(ints,1,4,99);
+        System.out.println(Arrays.toString(ints));
+    }
+}

BIN
target/classes/com/sf/Test2.class


BIN
target/classes/com/sf/day07/FDJ.class


BIN
target/classes/com/sf/day07_2/Animal.class


BIN
target/classes/com/sf/day07_2/AnimalTest.class


BIN
target/classes/com/sf/day07_2/Test.class