我的Java學(xué)習(xí)筆記

break以及continue

package com.iteasyup.javase;

public class break關(guān)鍵字 {

    //循環(huán)1-10但是當(dāng)我循環(huán)到5的時候循環(huán)結(jié)束
    //循環(huán)1-10但是循環(huán)到5的時候跳過5輸出
    
    public static void main(String[] args) {
        
        
//      for (int i = 1; i <= 10; i++) {
//          System.out.println(i);
//          if (i == 5) {
//              //break:結(jié)束當(dāng)前循環(huán)
//              break;
//          }
//      }
        
        for (int i = 1; i < 11; i++) {
            if (i == 5) {
                //continue:跳過本次循環(huán),進(jìn)入下一次循環(huán)
                continue;
            }
            System.out.println(i);
        }
        
        
    }
}

collection的使用

package com.iteasyup.javase;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionTest {

    public static void main(String[] args) {
        
        //創(chuàng)建Collection集合對象
        //泛型:集合存儲的數(shù)據(jù)的數(shù)據(jù)類型席赂,jdk1.5以后才出現(xiàn)的
        //只能寫引用類型
        Collection<Integer> coll = new ArrayList<>();
        
        //添加數(shù)據(jù)信息
        coll.add(10);
        coll.add(20);
        coll.add(30);
        coll.add(30);
        
        //刪除數(shù)據(jù)
        coll.remove(20);
        
        //修改數(shù)據(jù):
        coll.remove(10);
        coll.add(40);
        
        //求集合元素個數(shù)的方法棵癣,即長度
        int size = coll.size();
        System.out.println(size);
        
        //判定集合中是否包含某元素
        System.out.println(coll.contains(50));
        
        //判定集合是否為空
        System.out.println(coll.isEmpty());
        
        //輸出集合中的數(shù)據(jù)
        for (Integer a : coll) {
            System.out.println(a);
        }
        //直接打印對象名堂竟,也可以輸出
        System.out.println(coll);
        
        //迭代器的方式輸出
        Iterator<Integer> iterator = coll.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}

do while循環(huán)以及while循環(huán)的區(qū)別

package com.iteasyup.javase;

public class 循環(huán)之dowhile {

    public static void main(String[] args) {
        
        //循環(huán)輸出1-10
//      int i = 1;
//      do {
//          System.out.println(i);
//          i++;
//      } while (i < 11);
        
        //輸出1+2+3+4+5=?
        
//      int s = 0;
//      int i = 1;
//      do {
//          s = s + i;
//          i++;
//      } while (i < 6);
//      System.out.println(s);
        
        
        //雞兔同籠,一共35個頭玛迄,94只腳,雞多少只颖变,兔多少只
        
        int i = 1;
        do {
            if (i * 2 + (35-i) * 4 == 94) {
                System.out.println("雞有:" + i + "只掌实;" + "兔有:" + (35 - i) + "只");
            }
            i++;
        } while (i < 36);
        
        //while循環(huán)和do while循環(huán)之間的區(qū)別
        //①while循環(huán)先判斷后執(zhí)行陪蜻,不一定有結(jié)果
        //②do while循環(huán)先執(zhí)行后判斷,一定至少會有一個結(jié)果
    }
    
}

foreach循環(huán)

package com.iteasyup.javase;

public class foreac循環(huán) {

    public static void main(String[] args) {
        
        //定義一個數(shù)組
        int[] a = {11,22,33,44,55};
        
        //foreach循環(huán)遍歷數(shù)據(jù)
        //int表示循環(huán)數(shù)組的數(shù)據(jù)類型  i用于表示數(shù)組中的所有元素的變量名(可以自定義)
        //a表示要循環(huán)數(shù)組的變量名
        for (int i : a) {
            System.out.println(i);
        }
        
        String[] b = {"da","ji","ge","you","are","beautiful"};
        
        for (String bb : b) {
            System.out.println(bb);
        }
    }
}

for死循環(huán)

package com.iteasyup.javase;

import java.util.Scanner;

public class for死循環(huán) {

    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        
//      for (int i = 1; i < 2; i--) {
//          System.out.println(i);
//      }
        
//      for (; ; ) {
//          System.out.println("大吉哥好帥");
//      }
        
        for (; ; ) {
            System.out.println("請選擇:1.VIP會員 2.普通會員 3.刪除會員信息 4.添加會員信息 5.退出");
            int choose = in.nextInt();
            if (choose == 1) {
                System.out.println("VIP會員");
            }
            if (choose == 2) {
                System.out.println("普通會員");
            }
            if (choose == 3) {
                System.out.println("刪除會員信息");
            }
            if (choose == 4) {
                System.out.println("添加會員信息");
            }
            if (choose == 5) {
                System.out.println("退出系統(tǒng)");
                break;
            }
        }
    }
    }

lambda運(yùn)算符的使用

package com.iteasyup.javase;

public class T01 {

    //java8新特性:lambda
    //結(jié)構(gòu)
    //(參數(shù)) -> {執(zhí)行體}
    //函數(shù)式編程(接口)(一個接口只有一個抽象方法)
    
    public int f1(Math math, int a, int b) {
        return math.js(a, b);
    }
    
    public static void main(String[] args) {
        
        T01 t01 = new T01();
//      Math math = () -> 執(zhí)行體
        Math math = (a, b) -> a + b;
        int f1 = t01.f1(math, 3, 5);
        
        System.out.println(f1);
        
    }

}


package com.iteasyup.javase;

public interface Compare {

    String compareTo(String s1, String s2);
}

package com.iteasyup.javase;

public class TestCompare {

    public void f1(Compare compare, String s1, String s2) {
        System.out.println(compare.compareTo(s1, s2));
    }
    
    public static void main(String[] args) {
        Compare compare = (s1, s2) -> {
            if (s1.length() - s2.length() > 0) {
                return s1;
            }
            else {
                return s2;
            }
        };
        new TestCompare().f1(compare, "liuji", "dajige");
    }
}

List的使用

package com.iteasyup.javase;

import java.util.ArrayList;
import java.util.List;

public class TestList {

    public static void main(String[] args) {
        //創(chuàng)建List集合
        List<String> list = new ArrayList<>();
        
        //添加數(shù)據(jù)
        list.add("葉秋");
        list.add("葉修");
        list.add("陳果");
        list.add("葉秋");
        
        //刪除list集合中某條元素,可以寫索引贱鼻,也可以寫值
        list.remove(2);
        
        //修改list集合中的某個元素
        list.set(1, "a");
        
        //獲取list集合中的某個元素
        System.out.println(list.get(0));

        //for循環(huán)輸出整個List集合
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        //直接輸出list中所有元素
        System.out.println(list);
    }
}

main以及syso輸出

package com.iteasyup.javase;

public class Test1 {

    //java代碼
    // main方法 作用:java代碼的運(yùn)行主程序 想要運(yùn)行java
    //代碼時宴卖,必須提供 快捷鍵 main+enter鍵
    public static void main(String[] args) {
        //syso java輸出語句
        //快捷鍵 syso+enter
        System.out.println(10);
        System.out.println("hello world");
        System.out.println();
    }
}

map的使用

package com.iteasyup.javase;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestMap {

    public static void main(String[] args) {
        //創(chuàng)建一個map集合
        //有HashMap滋将,Hashtable
        //HashMap和Hashtable之間的區(qū)別:
        //①HashMap中可以將null當(dāng)成鍵或者值,Hashtable不可以
        //②HashMap線程不安全症昏,速度快耕渴;Hashtab線程安全,速度慢
        
        Map<Integer, String> map = new HashMap<>();
        
        //添加數(shù)據(jù)
        //null既可以當(dāng)key齿兔,也可以當(dāng)value橱脸,但是只有在 new HashMap的時候可以
        map.put(1, "小王");
        map.put(2, "小黑");
        map.put(3, "小白");
        map.put(null, null);
        
        //刪除
        map.remove(2);
        map.remove(3, "小黑");
        
        //修改,map中如果key重復(fù)分苇,會獲取最后一個值
        map.put(1, "效率");
        
        //取值:通過鍵
        System.out.println(map.get(1));
        
        //想要獲取所有的鍵添诉,返回一個Set集合
        Set<Integer> keys = map.keySet();
        
        for (Integer integer : keys) {
            System.out.println(map.get(integer));
        }
        
        //直接獲取所有的值,返回一個Collection集合
        Collection<String> values = map.values();
        for (String string : values) {
            System.out.println(string);
        }
        
        //直接輸出map
        System.out.println(map);
    }
}

Reader医寿、Writer+Buff

package com.iteasyup.javase;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

public class Test9 {

    public static void main(String[] args) throws IOException {
        
        File file = new File("D:\\xiaoli.txt");
        File file2 = new File("D:\\test6.txt");
        
        Reader reader = new FileReader(file);
        Writer writer = new FileWriter(file2);
        
        BufferedReader b = new BufferedReader(reader);
        BufferedWriter w =  new BufferedWriter(writer);
        
        String s = "";
        while ((s = b.readLine()) != null) {
            System.out.println(s);
            s = s.replace("小", "大");
            System.out.println(s);
            w.write(s + "\r\n");
        }
        
        w.close();
        b.close();
        writer.close();
        reader.close();
    }
}

Reader+Buff

package com.iteasyup.javase;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class TestBufferedReader {

    public static void main(String[] args) throws IOException {
        
        File file = new File("D:\\aa.txt");
        
        Reader reader = new FileReader(file);
        
        //創(chuàng)建緩沖流
        BufferedReader br = new BufferedReader(reader);
        
        String s1 = "";
        
        while ((s1 = br.readLine()) != null) {
            System.out.println(s1);
        }
        
        br.close();
        reader.close();
    }
}

Reader的使用

package com.iteasyup.javase;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

public class TestReader {

    public static void main(String[] args) {
        
        //1.創(chuàng)建file對象
        File file = new File("D:\\aa.txt");
        
        //2.創(chuàng)建字符輸入流
        Reader reader = null;
        try {
            reader = new FileReader(file);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        //3.讀數(shù)據(jù)
        int result = 0;
        try {
            if (reader != null) {
                while((result = reader.read()) != -1) {
                    System.out.println((char)result);
                }
            }
            
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
}

Set的使用及其與List之間的區(qū)別

package com.iteasyup.javase;

import java.util.HashSet;
import java.util.Set;

public class TestSet {

    public static void main(String[] args) {
        
        //List集合和Set集合之間的區(qū)別栏赴?
        //Set集合無序、值不可重復(fù)靖秩、無索引
        //List集合有序须眷、值可重復(fù)、有索引
        //Collection集合無序沟突,值可重復(fù)
        
        //Set集合如何去除重復(fù)數(shù)據(jù)
        //①Set可以自動去除String類的重復(fù)數(shù)據(jù)
        //②Set不能自動去除通過創(chuàng)建對象的重復(fù)變量行您,
        //需要重寫hashcode(比較當(dāng)前對象是否一樣)糯崎,和equals方法(比較堆空間的值),即source下點(diǎn)擊
        
        
        //創(chuàng)建set集合
        Set<String> set = new HashSet<>();
        
        //添加數(shù)據(jù)
        set.add("aa");
        set.add("bb");
        set.add("cc");
        set.add("dd");
        
        //刪除元素
//      set.remove("cc");
//      
//      //更新
//      set.remove("dd");
//      set.add("xx");
        
        
        //獲取set里面的元素
        //①foreach
        for (String string : set) {
            System.out.println(string);
        }
        
        //②直接輸出集合名
        System.out.println(set);
    }
}

Set下面的update和delete方法

package com.jihezonghlianxi.javase;

public class StudentCheckSet implements StudentCheck{

    @Override
    public void addStudent(Student student) {
        Modle.SET.add(student);
    }

    @Override
    public void deleteStudent(int id) {
        Student s1 = null;
        for (Student student : Modle.SET) {
            if (student.getId() == id) {
                s1 = student;
            }
        }
        //foreach循環(huán)底層是迭代器,如果刪除就會變?yōu)閚ull妇押,下一層就無法循環(huán)葫辐,會出現(xiàn)錯誤
        Modle.SET.remove(s1);
    }

    @Override
    public void updateStudent(int id, Student student) {
        //這幾個方法都沒被static修飾蹬挺,并且在同一個類下唬滑,可以直接調(diào)用
        deleteStudent(id);
        addStudent(student);
    }
}

switch語句

package com.iteasyup.javase;

import java.util.Scanner;

public class Testswitch語句 {

    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        // 需求:輸入1個數(shù)字來表示周幾,如果輸入1域携,打印周一吃方便面
        //如果輸入2簇秒,打印周二吃面條
        //如果輸入3,打印周三吃麻辣燙
        //如果輸入4秀鞭,打印周四吃米飯
        //如果輸入5趋观,打印周五吃餃子
        //如果輸入6,打印周六吃包子
        //如果輸入7气筋,打印周日喝白開水
        //否則拆内,輸出輸入錯誤,只能輸入1-7的數(shù)字
        
        System.out.println("請輸入一個數(shù)字:");
        int num = in.nextInt();
        
        switch (num) {
        case 1:
        case 3:
        case 5:
            System.out.println("周一三五吃方便面");
            break;
        case 2:
        case 4:
        case 6:
            System.out.println("周二四六喝白開水");
            break;
        case 7:
            System.out.println("周日吃米飯");
            break;
            

        default:
            System.out.println("輸入錯誤宠默,只能輸入1-7的數(shù)字");
            break;
        }
    }
}

while循環(huán)

package com.iteasyup.javase;

public class 循環(huán)之while {

    public static void main(String[] args) {
        
        //輸出1-10所有的數(shù)字
//      int i = 1;
//      while (i < 11) {
//          System.out.println(i);
//          i++;
//      }
        
        //輸出2 4 6 8 10
//      int i = 2;
//      while (i < 11) {
//          System.out.println(i);
//          i += 2;
//      }
        

        //輸出1 2 4 7 11 16
//      int i = 1;
//      int s = 1;
//      while (i <= 6) {
//          System.out.println(s);
//          s = s + i;
//          i++;
//      }
        
//      int i = 1;
//      int s = 0;
//      while (i <= 5) {
//          s = s + i;
//          System.out.println(s);
//          i++;
//      }
        
        int sum = 1;
        int i = 0;
        while (i < 6) {
            sum = sum + i;
            System.out.println(sum);
            i++;
        }
    }
}

Writer的使用

package com.iteasyup.javase;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class TestWriter {

    public static void main(String[] args) {
        
        //1.創(chuàng)建file類對象
        File file = new File("D:\\aa.txt");
        
        //2.創(chuàng)建字符輸出流
        Writer writer = null;
        try {
             writer = new FileWriter(file);
             //3.輸出數(shù)據(jù)
             String s1 = "小明說小利真丑";
             writer.write(s1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally {
            //4.關(guān)流
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
}

返回值

package com.iteasyup.javase;

public class ReturnType {

    //花錢買10元的水,將剩余的錢得到
    public static void main(String[] args) {
        int buywater = ReturnType.buywater(100);
        System.out.println(buywater);
    }
    
    
    public static int buywater(int money) {
        money = money - 10;
        return money;
    }
}

方法重載方便輸入

package com.iteasyup.javase;

public class Test {

    //方法重載:將方法名相同灵巧,參數(shù)列表不同的方法稱之為重載
    //重載發(fā)生在同一個類下搀矫,并且重載方法和返回值無關(guān)
    //***構(gòu)造方法可以重載
    //Java中抹沪,最大的重載方法是syso
    //求最大值max
    
    public int max(int a, int b) {
         return a > b ? a : b;
    }
    
    public double max(double a, double b) {
        return a > b ? a : b;
    }
}


package com.iteasyup.javase;

public class T01 {

    public static void main(String[] args) {
        
        //求兩個整數(shù)的最大值
        Test test =  new Test();
        int max = test.max(10, 29);
        System.out.println(max);
        
        double max2 = test.max(2.3, 5.6);
        System.out.println(max2);
    }
}

獲取當(dāng)前系統(tǒng)時間 日期 Date

package com.iteasyup.dao;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TestDate {

    public static void main(String[] args) {
        Date date = new Date();
        SimpleDateFormat now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = now.format(date);
        System.out.println(time);
    }
}

繼承關(guān)系的上下轉(zhuǎn)型

package com.iteasyup.com;

public class MasterTest {

    public static void main(String[] args) {
        
        //創(chuàng)建Master對象
        Master master = new Master();
        //創(chuàng)建參數(shù)對象
        Animal animal = new Cat();//對象的上轉(zhuǎn)型,只能調(diào)用父類和子類共有的方法
//      master.feed(animal);
        
        animal.eat();
        
        //對象的下轉(zhuǎn)型
        //用來調(diào)用子類獨(dú)有的方法
        Cat cat = (Cat)animal;
        cat.catchMoue();
    }
}

接口的結(jié)構(gòu)

package com.iteasyup.javase;

public interface Lock {

    FangDaoMen fangDaoMen = new FangDaoMen();
    
    //常量瓤球,必須用public修飾融欧,常量默認(rèn)被public static final修飾,
    //常量名最好大寫卦羡,不然有可能被誤認(rèn)為變量
    //用接口點(diǎn)的方式調(diào)用
    //不管是類下噪馏,還是接口下,常量必須賦值
    //如果在類下面定義一個常量绿饵,public static final不能省略
    public static final int A = 10;
    
    //抽象方法欠肾,可以將修飾符(不僅僅是訪問修飾符)省略
    //默認(rèn)存在修飾符public abstract,可以寫拟赊,也可以不寫
    void lock();
    void unlock();
}

進(jìn)程休眠的sleep和wait的區(qū)別以及死鎖

package com.iteasyup.javase;

public class T1 extends Thread {

    //sleep和wait的方法
    //1.sleep是Thread類下的方法刺桃,wait是object類下的方法
    //2.sleep有自醒時間,主動釋放鎖吸祟,wait需要被notify喚醒瑟慈,不主動釋放鎖
    
    //死鎖:由于同步代碼塊的嵌套,導(dǎo)致兩把鎖互相搶占彼此的資源屋匕,導(dǎo)致程序無法進(jìn)行葛碧,此時稱作死鎖。因此最好不要對鎖進(jìn)行嵌套过吻。
    //鎖必須找同一個人吹埠,必須寫引用類型(對象或者字符串)

    @Override
    public void run() {
        synchronized ("aa") {
            System.out.println("1");
            synchronized ("bb") {
                System.out.println(2);
            }
        }
    }
}


package com.iteasyup.javase;

public class T2 extends Thread{

    @Override
    public void run() {
        synchronized ("aa") {
            System.out.println(3);
            synchronized ("bb") {
                System.out.println(4);
            }
        }
    }
}

//sleep的創(chuàng)建方式
package com.iteasyup.javase;

public class Buyer extends Thread{

    @Override
    public void run() {
        for(;;) {
            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (Market.goods == 0) {
                System.out.println("已經(jīng)沒有貨物啦!");
                break;
            }
            Market.goods -= 5;
            System.out.println("買家買走貨物疮装,貨物剩余" + Market.goods + "份");
        }
    }
}


package com.iteasyup.javase;

public class T2 extends Thread {
    @Override
    public void run() {
        synchronized ("bb") {
            System.out.println(3);
            synchronized ("aa") {
                System.out.println(4);
            }
//          for (int i = 1; i < 21; i++) {
//              System.out.println("線程二"+i);
//          }
//          "aa".notify();
        }
    }

}


package com.iteasyup.javase;

public class T1 extends Thread{
    @Override
    public void run() {
        synchronized ("aa") {
            System.out.println(1);
            synchronized ("bb") {
                System.out.println();
            }
//          try {
//              "aa".wait();
//          } catch (InterruptedException e) {
//              // TODO Auto-generated catch block
//              e.printStackTrace();
//          }
//          for (int i = 1; i < 21; i++) {
//              System.out.println("線程一"+i);
//          }
            
        }
    }

}

可變形參的用法

package com.iteasyup.javase;

public class Test {

    //可變形參缘琅,底層是數(shù)組
    public void f1(String...strings) {
        for (String string : strings) {
            System.out.println(string);
        }
    }
    
    public static void main(String[] args) {
        Test test = new Test();
        test.f1("aa", "bb", "cc", "dd");
    }
}

控制臺接值

package com.iteasyup.javase;

import java.util.Scanner;

public class 控制臺接值 {
    
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        
        System.out.println("請輸入一個整數(shù):");
        int a = in.nextInt();
        System.out.println(a);
        System.out.println("請輸入一個小數(shù):");
        double b = in.nextDouble();
        System.out.println(b);
        System.out.println("請輸入一個姓名:");
        String name = in.next();
        System.out.println(name);
    }
}

快速排序算法的Java代碼實(shí)現(xiàn)

package Ji1;

public class QuickSort {
    public static void quickSort(int[] arr,int low,int high){
        int i,j,temp,t;
        if(low>high){
            return;
        }
        i=low;
        j=high;
        //temp就是基準(zhǔn)位
        temp = arr[low];
 
        while (i<j) {
            //先看右邊,依次往左遞減
            while (temp<=arr[j]&&i<j) {
                j--;
            }
            //再看左邊廓推,依次往右遞增
            while (temp>=arr[i]&&i<j) {
                i++;
            }
            //如果滿足條件則交換
            if (i<j) {
                t = arr[j];
                arr[j] = arr[i];
                arr[i] = t;
            }
 
        }
        //最后將基準(zhǔn)為與i和j相等位置的數(shù)字交換
         arr[low] = arr[i];
         arr[i] = temp;
        //遞歸調(diào)用左半數(shù)組
        quickSort(arr, low, j-1);
        //遞歸調(diào)用右半數(shù)組
        quickSort(arr, j+1, high);
    }
 
 
    public static void main(String[] args){
        int[] arr = {10,7,2,4,7,62,3,4,2,1,8,9,19};
        quickSort(arr, 0, arr.length-1);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}

攔截器

package com.iteasyup.fifth.advice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class CommonIntercepter implements HandlerInterceptor{
    
    /**
     * 一刷袍、攔截器和過濾器的區(qū)別
     * 1. 攔截器,只能攔截發(fā)送給Controller的請求
     *    過濾器樊展,可以攔截發(fā)送給任何資源的請求
     * 2. 攔截器:由于屬于Spring管理呻纹,因此其可以獲取并注入Spring實(shí)例化的bean。也就是可以使用@Autowired
     *    過濾器:屬于Web應(yīng)用的組件专缠,不會被Spring管理雷酪,因此無法獲取Spring容器中的bean實(shí)例。也就是不可以使用@Autowired
     * 3. 攔截器:是基于反射 + 動態(tài)代理來實(shí)現(xiàn)的涝婉。
     *    過濾器:是基于方法回調(diào)實(shí)現(xiàn)的
     * 4. 攔截器:不依賴Servlet容器(本質(zhì)上哥力,攔截器沒有Tomcat也能工作)。
     *    過濾器:必須依賴Servlet容器
     * 5. 攔截器:可以攔截請求的三個階段:
     *           (1)請求發(fā)送到Controller之前;
     *           (2)請求被處理完吩跋,但是沒有渲染前寞射;
     *           (3)請求處理完,視圖渲染后锌钮;
     *    過濾器:只可以攔截請求發(fā)送到資源之前的階段桥温;
     */
    
    //在請求進(jìn)入controller之前攔截
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        System.out.println("preHandle execute...");
        return true;
    }

    //視圖渲染前攔截,在方法執(zhí)行完梁丘,還沒return侵浸,還沒jsp
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
            ModelAndView modelAndView) throws Exception {
        System.out.println("postHandle execute...");
    }

    //視圖渲染后攔截,jsp畫面已經(jīng)出來后
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
    System.out.println("afterCompletion execute...");
    }
}

需要在springmvc.xml中實(shí)例化該類氛谜,然后配置攔截路徑
    <mvc:interceptors>
        <mvc:interceptor>
        <!-- /**攔截所有請求掏觉,/a/b/*攔截后面沒有目錄的,/**/a/**攔截中間有目錄是a的 -->
        <!-- 攔截路徑 -->
            <mvc:mapping path="/**" />
            <!-- 實(shí)例化攔截器類 -->
            <bean class="com.iteasyup.fifth.advice.CommonIntercepter"></bean>
        </mvc:interceptor>
    </mvc:interceptors>

利用迭代器從collection中取出數(shù)據(jù)的方式

        //迭代器
        Iterator<String> it = coll.iterator();
        //集合調(diào)用iterator方法混蔼,會返回迭代器對象履腋,利用迭代器對象,幫助我們從集合中取數(shù)據(jù)
        //迭代器可以這么理解:
        //每次判斷從該集合的第一條開始惭嚣,判斷是否有值遵湖,如果有就打印出來,并且把指針移到下一條
        //下一條同樣執(zhí)行這個操作晚吞,如果已經(jīng)沒值了延旧,就結(jié)束循環(huán)
        while (it.hasNext()) {
            //it.hasNext():判斷集合中是否還有元素
            System.out.println(it.next());
            //it.next():取出集合中的下一條元素
        }

利用方法給當(dāng)前進(jìn)程命名以及取名和解決并發(fā)問題

package com.qita.javase;

public class TestTicket implements Runnable{

    //解決并發(fā)問題:
    //1.同步方法
    //2.同步代碼塊
    int ticket = 100;
    
    @Override
    public void run() {
        for(;;) {
            ticket();
        }
    }
    
    public synchronized void ticket()   {
        if (ticket >= 0) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "剩余票數(shù)為" + ticket-- + "張");
        }
    }

    public static void main(String[] args) {
        
        Runnable r1 = new TestTicket();
        Thread t1 = new Thread(r1);
        Thread t2 = new Thread(r1);
        Thread t3 = new Thread(r1);
        
        t1.setName("售票窗口一:");
        t2.setName("售票窗口二:");
        t3.setName("售票窗口三:");
        
        t1.start();
        t2.start();
        t3.start();
    }
}

利用面向?qū)ο髮?shù)組進(jìn)行賦值

package com.iteasyup.javase;

public class TestArray {

    int[] arr = new int[3];
    
    public void addArr(int a, int b , int c) {
        arr[0] = a;
        arr[1] = b;
        arr[2] = c;
        
    }
    
    public void selectArr() {
        for (int i : arr) {
            System.out.println(i);
        }
    }
    
    public static void main(String[] args) {
        TestArray s1 = new TestArray();
        s1.addArr(4, 56, 2);
        s1.selectArr();
    }
}

兩種利用進(jìn)程休眠打印時間的方式

package com.iteasyup.javase;

public class Time implements Runnable {

    @Override
    public void run() {
//      int h;
//      int m;
//      int s;
//      for (h = 0; h < 60; h++) {
//          for (m = 0; m < 60; m++) {
//              for (s = 0; s < 60; s++) {
//                  System.out.println("現(xiàn)在時間是:" + h + "時" + m + "分" + s + "秒");
//                  try {
//                      Thread.sleep(10);
//                  } catch (InterruptedException e) {
//                      // TODO Auto-generated catch block
//                      e.printStackTrace();
//                  }
//                  
//              }
//          }
//          
//          
//          
//      }
        
        for(int i = 0;;i++) {
            System.out.println("已經(jīng)過了"+ i/(3600 * 24 * 30 * 12) + "年" + i / (3600 * 24 * 30) % 13 + "月" + i / (3600 * 24) % 31 + "天" + i / 3600 % 25 + "時"+ i / 60 % 60 +"分" + i % 60 + "秒");
        }
        
    }
}

枚舉類

package com.iteasyup.fifth.test;

import lombok.Getter;

@Getter
public enum Season {
//  總的來說,枚舉類里面有私有的成員變量槽地,有參構(gòu)造器迁沫,以及get方法。
//  然后用有參構(gòu)造方法創(chuàng)建本類的對象捌蚊,并賦給相應(yīng)的屬性集畅,該對象默認(rèn)被public static final修飾
    
//  ①:enum和class、interface的地位一樣
//  ②:使用enum定義的枚舉類默認(rèn)繼承了java.lang.Enum缅糟,而不是繼承Object類挺智。枚舉類可以實(shí)現(xiàn)一個或多個接口。
//  ③:枚舉類的所有實(shí)例都必須放在第一行展示窗宦,不需使用new 關(guān)鍵字赦颇,不需顯式調(diào)用構(gòu)造器。自動添加public static final修飾赴涵。
//  ④:使用enum定義媒怯、非抽象的枚舉類默認(rèn)使用final修飾,不可以被繼承髓窜。
//  ⑤:枚舉類的構(gòu)造器只能是私有的扇苞。

    SPRING("溫暖", "春暖花開"),
    SUMMER("炎熱", "烈日炎炎"),
    AUTUMN("涼爽", "秋高氣爽"),
    WINTER("寒冷", "白雪皚皚");
    
    public String temporature; //溫度
    
    private String description; //描述
    
    private Season(String temporature, String description) {
        this.temporature = temporature;
        this.description = description;
    }
}

面試可能會問到的一些問題

package com.iteasyup.javase;

public class Test {

    public static void main(String[] args) {
        
    //創(chuàng)建字符串
    //類的結(jié)構(gòu)
    /*
     * 1.構(gòu)造方法
     * 2.方法(靜態(tài)方法,非靜態(tài)方法)
     * 3.成員變量
     * 4.代碼塊(靜態(tài)代碼塊,非靜態(tài)代碼塊)(代碼塊中的內(nèi)容就是當(dāng)類被運(yùn)行的時候就先被加載)
     * 5.內(nèi)部類
     */
        
        //當(dāng)父類和子類同時存在靜態(tài)代碼塊杨拐、非靜態(tài)代碼塊祈餐、構(gòu)造器時程序執(zhí)行順序
        //執(zhí)行順序
        /*
         * 父類靜態(tài)代碼塊
         * 子類靜態(tài)代碼塊
         * 父類非靜態(tài)代碼塊
         * 父類無參構(gòu)造器
         * 子類非靜態(tài)代碼塊
         * 子類無參構(gòu)造器
         */

        //靜態(tài)代碼塊,只能使用static修飾的內(nèi)容
//      static {
//          
//      }
        
        //非靜態(tài)代碼塊
//      {
//          
//          
//          
//      }
        
        //執(zhí)行順序:靜態(tài)代碼塊>非靜態(tài)代碼塊>無參構(gòu)造器
        //靜態(tài)先加載擂啥,非靜態(tài)創(chuàng)建對象的時候加載
        //靜態(tài)代碼塊哄陶,存在于靜態(tài)域中,只會被加在一塊兒

        
        //內(nèi)部類
        //也分為靜態(tài)和非靜態(tài)哺壶,
        //在非靜態(tài)內(nèi)部類中不可以寫與任何與靜態(tài)相關(guān)的東西
        //內(nèi)部類也可以被訪問修飾符修飾
        class T01{
            int a = 10;
            public void f22() {
                System.out.println(a);
            }
        }
        
    //4個訪問修飾符:控制方法屋吨、變量訪問范圍
    /**
     * private:私有化,只能在當(dāng)前類下使用
     * default:沒有訪問修飾符的時候山宾,默認(rèn)被它修飾至扰,但是如果寫出default來的話會報錯
     * protected:同包不同類可以訪問鞭盟,如果跨包的話必須存在一個繼承的關(guān)系,才能訪問
     * public:只要是保證在同一個項目下的任意類都可以訪問
     * 
     */
        
        
        /**
         *                  本類      同包不同類       跨包(父子類)     所有包所有類
         * priavate           √             ×                 ×                   ×
         * default            √             √                 ×                   ×
         * protected          √             √                 √                   ×
         * public             √             √                 √                   √
         */
        
        //訪問修飾符可以修飾的東西
        /**
         * 1.類
         * 2.普通方法
         * 3.成員變量
         * 4.構(gòu)造器
         * 5.內(nèi)部類
         */
        /*
         * 
         */
        
        //面試問題:
        
        //數(shù)組必須指明長度。
        //初始化成員變量有幾種方式:
        //①顯示初始化(直接賦值)
        //②默認(rèn)初始化(成員變量有默認(rèn)值)
        //③對象初始化(創(chuàng)建對象 對象.成員變量)
        //④構(gòu)造器初始化
        //⑤代碼塊初始化
        //實(shí)例化 == 創(chuàng)建對象
        //請解釋什么是實(shí)例變量和類變量
        //實(shí)例變量就是沒有被static修飾的變量
        //類變量就是被static修飾的變量,隨著類的加載而加載箱亿,存在于靜態(tài)域中必盖,不會重復(fù)加載
        //JavaBean
        //存在無參構(gòu)造器的類俱饿,稱之為JavaBean
        //pojo
        //帶有g(shù)et歌粥、set方法的類稱之為pojo類

    String s1 = "Hello";
    String s2 = new String("java");
    System.out.println(s2);
    }
}

面向?qū)ο蟮囊话惴椒ㄕ{(diào)用和成員變量的賦值

package com.iteasyup.javase;

public class Student {

    //姓名
    String name;
    //
    int no;
    //學(xué)生的年齡
    int age;
    
    //好好學(xué)習(xí)
    //沒有static需要使用類來調(diào)用
    public void study() {
        System.out.println("好好學(xué)習(xí)");
    }
    
    //學(xué)生
    public void showStudentLife() {
        System.out.println("逃課");
        System.out.println("掛科");
        System.out.println("談戀愛");
    }
}

package com.iteasyup.javase;

public class StudentTest {

    public static void main(String[] args) {
        
        //創(chuàng)建學(xué)生對象
        Student s1 = new Student();
        s1.name = "劉吉";
        s1.age = 22;
        s1.no = 1001;
        s1.study();
        
        System.out.println(s1.name);
        System.out.println(s1.age);
        System.out.println(s1.no);
        
        //創(chuàng)建第二個學(xué)生對象
        Student s2 = new Student();
        s2.name = "珠蘭";
        s2.age = 10;
        s2.showStudentLife();
        System.out.println("該學(xué)生的姓名為" + s2.name + ",她的年齡是" + s2.age + "歲");
        System.out.println(s2.no);
    }
}

全部數(shù)據(jù)類型以及注釋方式

package com.iteasyup.javase;

/**
 * 
 * @author ji.liu
 * @since 2019.07.11
 */
public class 數(shù)據(jù)類型 {

    public static void main(String[] args) {
        
//      //java數(shù)據(jù)類型
//      //1.基本數(shù)據(jù)類型
//      //2.引用類型
//      
//      
//      /*
//       * 多行注釋
//       * 基本數(shù)據(jù)類型8個
//       * ①整數(shù)型: byte   short   int long
//       * ②浮點(diǎn)型float double
//       * ③布爾型boolean
//       * ④字符型char
//       * 
//       * 
//       * 
//       */
//      //字節(jié)類型
//      byte a = 10;
//      //a + 1 之后的結(jié)果是多少
//      //int 強(qiáng)轉(zhuǎn)(大類型轉(zhuǎn)換為小類型)byte
//      a =(byte)(a + 1);
//      System.out.println(a);
//      //java中存不存在一個數(shù)加1之后小于它本身
//      //比如byte的127加一會變成-128稍途,相當(dāng)于一個循環(huán)
//      
//      byte b = 127;
//      b += 1;
//      System.out.println(b);
//      
//      
//      //短整型
//      short s = 32767;
//      
//      //整型
//      int i = 1000000202;
//      
//      //長整型
//      long l = 123;
//      //超過int類型范圍的數(shù)阁吝,要在數(shù)值的后面加大寫或小寫的L
//      long p = 1777897139719237497L;
//      
//      //高精度
//      double d = 1.7947177383910299101838319;
//      //低精度
//      float f = 12390.332f;
//      
//      //布爾值
//      boolean b1 = true;
//      
//      //字符型
//      char c = 'a';
//      char c1 = '我';
//      char c2 = 122;
//      System.out.println(c2);
//      //字符在java里面用asc碼
//      
//      char c3 = 25105;
//      System.out.println(c3);
//      System.out.println(c1);
//      
        //null是引用類型的默認(rèn)值
        
        //&&和&都是并且
        //①&&如果左側(cè)條件已經(jīng)不成立,就不執(zhí)行右側(cè)的條件械拍,直接返回false
        //②&先判斷符號左側(cè)突勇,即使為false也會判斷右側(cè)代碼,最后返回false
        //&位運(yùn)算符(與)(二進(jìn)制都為1坷虑,則為1)
        //|(或)(二進(jìn)制有1則為1)
        //^(異或)(二進(jìn)制相同為0甲馋,不同為1),可以用來交換兩個變量的數(shù)據(jù)
        //<< >>左移右移運(yùn)算符
        
//      String s1 = null;
//          if (1 == 2 && s1.length() == 1)  {
//              System.out.println("成功");
//          }else {
//              System.out.println("失敗");
//          }
        
        int a = 10;
        int b = 20;
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        System.out.println(a);
        System.out.println(b);
//      System.out.println(10 | 8);
        
        System.out.println(10 >> 2);
    }
}

全局變量和局部變量

package com.iteasyup.javase;

public class Person {

    String name;
    int age;
    String sex;
    
    //當(dāng)成員變量和局部變量同名時,
    //使用this.來區(qū)分誰是成員變量
    //this.表示當(dāng)前類的對象
    //成員變量和局部變量和局部變量之間的區(qū)別
    //①局部變量定義在方法內(nèi)迄损,成員變量定義在方法外定躏,類下
    //②局部變量必須賦值,成員變量有默認(rèn)值
    
    public void changeName(String n) {
        name = n;
    }
    
    public void addAge() {
        age += 18;
    }
    
    public void showPerson() {
        System.out.println("此人姓名為:" + name + "芹敌;年齡:" + age + "歲痊远;性別為:" + sex);
    }
    
    public static void main(String[] args) {
        
        Person p1 = new Person();
        Person p2 = new Person();
        
        p1.sex = "男";
        p1.changeName("劉吉");
        p1.addAge();
        p1.showPerson();
        p2.showPerson();
    }
}

如何從控制臺獲得數(shù)字定義數(shù)組

package com.iteasyup.javase;

import java.util.Scanner;

public class 第二種定義數(shù)組的方式 {

    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        
        //數(shù)組特點(diǎn):
        //數(shù)組中存儲的數(shù)據(jù)類型必須一致
        //數(shù)組定義的時候必須指明長度
        //定義數(shù)組
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("請輸入第" + (i + 1) + "個數(shù):");
            arr[i]= in.nextInt();
        }
        
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}

如何遞歸輸出1-5

public static void main(String[] args) {
        //利用遞歸的方式,輸出1~5
        m1(1);
    }
    public static void m1(int i) {
        System.out.println(i);
        i++;
        if (i == 6) {
            return;
        }
        m1(i);
    }

如何對set里面的數(shù)據(jù)進(jìn)行排序

package com.iteasyup.javase;

import java.util.Set;
import java.util.TreeSet;

public class TestTreeSet {

    public static void main(String[] args) {
        
        //排序Set集合中的數(shù)據(jù)
        //創(chuàng)建TreeSet實(shí)現(xiàn)類對象氏捞,重寫hashCode碧聪、equals方法,重寫toString
        //實(shí)現(xiàn)comparable接口液茎,重寫compareTo方法

        Set<Student> set = new TreeSet<>();
        
        Student s1 = new Student("小紅", 21);
        Student s2 = new Student("小白", 24);
        Student s3 = new Student("小黑", 56);
        Student s4 = new Student("小花", 29);
        
        set.add(s1);
        set.add(s2);
        set.add(s3);
        set.add(s4);
        
        System.out.println(set);
    }
}

package com.iteasyup.javase;

public class Student implements Comparable<Student> {

    String name;
    int age;
    
    public Student(String name, int age) {
        super();
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Student o) {
        // TODO Auto-generated method stub
        return this.age - o.age;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + age;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Student other = (Student) obj;
        if (age != other.age)
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Student [name=" + name + ", age=" + age + "]";
    }
}

如何獲得一個整數(shù)的個位逞姿、十位辞嗡、千位的數(shù)字

package com.iteasyup.javase;

public class 取余數(shù) {
public static void main(String[] args) {
    //1.求余數(shù)
    System.out.println(5 % 3);
    //2.求某個數(shù)的各個位數(shù)的值是多少
    int a = 12345;
    //個位
    System.out.println(a % 10);
    //十位
    System.out.println(a / 10 % 10);
    //百位
    System.out.println(a / 100 % 10);
    //千位
    System.out.println(a / 1000 % 10);
    //萬位
    System.out.println(a / 10000 % 10);
    
    //判斷10能否被3整除
//  if (10 % 3 == 0) {
//      System.out.println("能整除");
//  }
}
}

如何獲取1—100中所有的素數(shù)

package com.iteasyup.javase;

public class 循環(huán)拓展題5 {

    public static void main(String[] args) {
        
        for (int i = 1; i < 101; i++) {
            int s = 0;
                for (int j = 1; j < i + 1; j++) {
                    if (i % j == 0) {
                        ++s;
                    }
                }
                
                if (s == 2) {
                    System.out.println("素數(shù)有:"+ i);
                }
            }
        }
    }

如何進(jìn)行冒泡排序以及如何把一個數(shù)組中符合要求的數(shù)字轉(zhuǎn)移到另一個數(shù)組

package com.iteasyup.javase;

import java.util.Scanner;

public class 擴(kuò)展題唱歌比賽 {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        
        int[] a = new int[6];
        for (int i = 0; i < a.length; i++) {
            System.out.println("請輸入第" + (i + 1) + "評委成績:");
            a[i] = in.nextInt();
        }
        
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a.length - 1; j++) {
                int temp = 0;
                if (a[j] > a[j+1]) {
                    temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
            }
        }
        
        for (int i = 0; i < a.length; i++) {
            System.out.println("a的數(shù)組:" + a[i]);
        }
        
        int[] b = new int[a.length - 2];
        int j = 0;
        for (int i = 0; i < a.length; i++) {
            if (i != 0 && i != a.length - 1) {
                b[j] = a[i];
                j++;
            }
        }
        
        for (int i = 0; i < b.length; i++) {
            System.out.println("b數(shù)組:" + b[i]);
        }
        
        double sum = 0;
        for (int i = 0; i < b.length; i++) {
            sum = sum + b[i];
        }
        
        System.out.println("選手的平均成績?yōu)椋? + sum/b.length + "分");
        
        另一種冒泡:
        int i;
        int j;
        int a[] = {5, 9, 6, 8, 7};
        
        for (i = 0; i < a.length - 1; i++) {
            int k = i;
            for (j = i; j < a.length; j++) {
                if (a[j] < a[k]) {
                    k = j;
                }
                int temp = a[i];
                a[i] = a[k];
                a[k] = temp;
            }
        }
        for (i = 0;  i < a.length; i++) {
            System.out.println(a[i] + "");
            System.out.println();
        }
    }
}

如何進(jìn)行字符串之間的比較

package com.iteasyup.javase;

import java.util.Scanner;

public class 條件分支語句 {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        //如果輸入的成績大于60,輸出及格滞造,否則輸出不及格
        System.out.println("請輸入學(xué)生成績:");
        double score = in.nextDouble();
        //if(條件:布爾表達(dá)式) {代碼執(zhí)行體}
//      if (score >= 60) {
//          System.err.println("及格");
//      } else {
//          System.out.println("不及格");
//      }
        
        if (score >= 90 && score <= 100) {
            System.out.println("優(yōu)秀");
        }else if (score >= 80 && score < 90) {
            System.out.println("良好");
        }else if (score >= 60 && score < 80) {
            System.out.println("及格");
        }else if (score >= 0 && score <60) {
            System.out.println("不及格");
        }else {
            System.out.println("成績必須在0-100之間");
        }
    }
}

如何讓最后一個被打印的數(shù)后面沒有逗號或其它字符

package com.iteasyup.javase;

public class 數(shù)組程序5 {

    public static void main(String[] args) {
        
        int[] a = {2,2,5,5,3};
        for (int i = 0; i < a.length; i++) {
            if (i == a.length - 1) {
                System.out.print(a[i]);
            }else {
            System.out.print(a[i] + "续室,");
            }
        }   
    }
}

public static void f1(String s) {
        String[] strings = s.split(",");
        int count = 0;
        for (int i = 0; i < strings.length; i++) {
            int a = Integer.valueOf(strings[i]);
            if (a % 2 != 0) {
                count++;
                if (count == 1) {
                    System.out.print(a);
                }else {
                    System.out.print("," + a);
                }
            }
        }
    }

如何在保證安全性的前提下對成員變量進(jìn)行賦值

package com.iteasyup.javase;

public class User {

    String cardNo;//卡號
    private double money;//錢
    String password;//密碼
    
    //公開給成員變量賦值的方法
    public void setMoney(double money) {
        if (money >= 0) {
            this.money = money;
        }
        else {
            System.out.println("輸入錯誤");
        }
    }
    
    //取值
    public double getMoney() {
        return money;
    }
}

package com.iteasyup.javase;

public class UserTest {

    public static void main(String[] args) {
        
        //創(chuàng)建用戶對象,給用戶對象賦值
        User user = new User();
        user.cardNo = "123456789";
        user.setMoney(-1000);
        user.password = "1qaz";
        
        System.out.println(user.cardNo);
        System.out.println(user.getMoney());
        System.out.println(user.password);
    }
}

如何在使用有參構(gòu)造方法的時候谒养,從控制臺接值

package com.lingyige.javase;

public class Student {

    int no;
    int age;
    String name;
    
    public Student(int no, int age, String name) {
        this.no = no;
        this.age = age;
        this.name = name;
    }
    
    public void showStudent() {
        System.out.println("這個學(xué)生名字叫做:" + name + "挺狰,年齡為:" + age + ",學(xué)號為:" + no);
    }
}

package com.lingyige.javase;

import java.util.Scanner;

public class StudentTest {

    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        System.out.println("請輸入編號:");
        int no = in.nextInt();
        System.out.println("請輸入年齡:");
        int age = in.nextInt();
        System.out.println("請輸入姓名:");
        String name = in.next();
        Student student = new Student(no, age, name);
        
        student.showStudent();
    }
}

三目運(yùn)算符

package com.iteasyup.javase;

import java.util.Scanner;

public class 三目運(yùn)算符 {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        
        //利用三目運(yùn)算符實(shí)現(xiàn)比較兩個數(shù)的大小
        System.out.println("請輸入第一個值:");
        int a = in.nextInt();
        System.out.println("請輸入第二個值:");
        int b = in.nextInt();
        System.out.println("請輸入第三個值:");
        int c = in.nextInt();
        // String max = a > b ? "最大值" + a : "最大值" + b;
        // System.out.println();
        
        //求三個數(shù)的最大值
        System.out.println((a > b ? a : b) > c ? (a > b ? a : b) : c);
        //業(yè)務(wù)的時候用if語句蝴光,但是寫更底層的時候使用三目運(yùn)算符
    }
}

刪除list中重復(fù)的元素

public static List removeDuplicate(List list)  {       
          for  (int i = 0; i < list.size() - 1; i ++ )  {       
              for  (int j = list.size() - 1; j > i; j --)  {       
                   if  (list.get(j).equals(list.get(i)))  {       
                      list.remove(j);       
                    }        
                }        
              }        
            return list;       
        }

設(shè)計模式:單例模式

package com.jihezonghlianxi.javase;

public class User {

    String accont;
    String pasword;
    
    //如何實(shí)現(xiàn)單例模式的設(shè)計模式
    
    //1.私有化構(gòu)造器
    private User() {

    }
    
    //2.創(chuàng)建私有靜態(tài)的final修飾的本類對象
    private static final User USER = new User();
    
    //3.公開的靜態(tài)的返回值為本類對象的方法
    public static User getUser() {
        return USER;
    }
}

package com.jihezonghlianxi.javase;

public class UserTest {

    public static void main(String[] args) {
        
//      User user = new User();
//      user.accont = "a";
//      user.pasword = "b";

        User user = User.getUser();
        user.accont = "a";
        user.pasword = "b";
        User user1 = User.getUser();
        user1.accont = "a";
        user1.pasword = "b";
    }
}

設(shè)計模式:適配器模式

package com.jihezonghlianxi.javase;

public interface TestDao {

    //為什么要用適配器模式:
    //1.當(dāng)接口添加方法的時候她渴,實(shí)現(xiàn)該接口的類达址,里面的方法也需要添加蔑祟。
    //2.如果繼承實(shí)現(xiàn)多個接口的話,就會有自己不想要的方法沉唠。

    //如何實(shí)現(xiàn)適配器模式
    //1.找到1個實(shí)現(xiàn)類實(shí)現(xiàn)接口疆虚,重寫接口下的所有方法
    //2.找1個子類繼承實(shí)現(xiàn)類,只重寫你想要的抽象方法
    void f1();
    void f2();
    void f3();
    void f4();
    void f5();
}

package com.jihezonghlianxi.javase;

public class TestDaoImpl implements TestDao {

    @Override
    public void f1() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void f2() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void f3() {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void f4() {
        // TODO Auto-generated method stub
    }

    @Override
    public void f5() {
        // TODO Auto-generated method stub
    }
}

package com.jihezonghlianxi.javase;

public class TestChild extends TestDaoImpl{

    @Override
    public void f1() {
        // TODO Auto-generated method stub
        super.f1();
    }
    
    @Override
    public void f2() {
        // TODO Auto-generated method stub
        super.f2();
    }
}

輸出斐波那契數(shù)列

利用數(shù)組和for循環(huán)輸出斐波那契數(shù)列
package com.iteasyup.javase;

import java.util.Scanner;

public class 斐波那契數(shù)列 {

    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        
//      //1 1 2 3 5 8 13
//      int[] a = new int[10000];
//      a[0] = 1;
//      a[1] = 1;
//      
//      for (int i = 2; i < a.length; i++) {
//          a[i] = a[i - 2] + a[i - 1];
//      }
//      
//      System.out.println("請輸入你想知道第幾位數(shù)字:");
//      
//      int b = in.nextInt();
//      
//      System.out.println("該位數(shù)字是:" + a[b]);
        
//      int[] arr = new int[5];
//      arr[0] = 1;
//      arr[1] = 1;
//      for (int i = 2; i < arr.length; i++) {
//          arr[i] = arr[i - 1] + arr[i - 2];
//      }
//      
//      System.out.println(arr[5 - 1]);
    }
}

//利用遞歸的方式輸出斐波那契數(shù)列
package com.iteasyup.javase;

public class Fibonacci {

    public static void f1(int[] a, int i) {

        a[i] = a[i - 1] + a[i - 2];
        System.out.println(a[i]);
        i++;
        if (i > 1000) {
            return;
        }
        f1(a, i);
    }
    
    
    public static void main(String[] args) {
        //利用遞歸的方式满葛,輸出一個斐波那契數(shù)列
        int[] a = new int[10000];
        a[0] = 1;
        a[1] = 1;
        int i = 2;
        f1(a,i);
        
    }
}

輸出流的使用

package com.iteasyup.javase;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class TestOutputStream {

    public static void main(String[] args) throws IOException {
        
        //1.找到文件
        File file = new File("D:\\aa.txt");
        
        //2.創(chuàng)建字節(jié)輸出流
        OutputStream os = new FileOutputStream(file);
        
        //3.寫出數(shù)據(jù)
        String s1 = "helloworld";
        os.write(s1.getBytes());
        
        //4.關(guān)閉流
        os.close();
    }

    private static OutputStream FileOutputStream(File file) {
        // TODO Auto-generated method stub
        return null;
    }
}

輸入流+buff

package com.iteasyup.javase;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class TestBufferedInputStream {

    public static void main(String[] args) throws IOException {
        
        //1.創(chuàng)建file對象
        File file = new File("D:\\bb.txt");
        
        //2.創(chuàng)建字節(jié)流
        InputStream is = new FileInputStream(file);
        
        //3.創(chuàng)建緩沖流
        BufferedInputStream bis = new BufferedInputStream(is);
        
        //4.讀數(shù)據(jù)
        int a = 0;
        while ((a = bis.read()) != -1) {
            System.out.println((char)a);
        }
        
        //5.關(guān)閉
        bis.close();
        is.close();
    }
}

輸入流的使用

package com.iteasyup.javase;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class TestInputstream {

    public static void main(String[] args) throws IOException {
        
        //D:\aa.txt
        //1.找到操作的文件
        File file = new File("D:\\aa.txt");
        //2.創(chuàng)建字節(jié)輸入流
        InputStream is = new FileInputStream(file);
        
        //3.通過流讀數(shù)據(jù)
        int result = 0;
        while(((result) = is.read()) != -1) {
            System.out.println((char)result);
        }
        
        //4.關(guān)閉流
        is.close();
    }
}

數(shù)據(jù)類型以及如何進(jìn)行字符串之間的比較

package com.iteasyup.javase;

public class Test2 {

    public static void main(String[] args) {
        //java中數(shù)據(jù)類型的定義
        //1.定義整數(shù)類型
        int a = 10;
        int b = 20;
        int c = a / b;
        //ctrl+E可以差錯径簿,并修改
        //syso中看a的類型而不是值
        System.out.println(c);
        
        //2.小數(shù)類型
        //double
        double d = 1.5;
        double e = 2;
        System.out.println(d / e);
        
        //判斷a和b之間的大小
        //輸出true或者是false這樣的值的結(jié)果稱之為布爾值
        //得到布爾值的表達(dá)式稱之為布爾表達(dá)式
        //常用的邏輯運(yùn)算符:> < >= <= == !=
        //= 和 ==之間的區(qū)別
        //=:代表賦值的意思
        //==:代表數(shù)字類型之間的比較
        System.out.println(a != b);
        
        //布爾類型定義
        //boolean
        
        boolean b1 = true;
        boolean b2 = false;
        
        //字符串類型
        //所有String類型和其它任意類型做加法運(yùn)算表示拼接,不能去做加法之外的運(yùn)算
        //String
        String s1 = "java";
        String s2 = "1001";
        System.out.println(s1 + a);
        
        //判斷s1和s2不相等
        System.out.println(!s1.equals(s2));
        //判斷s1和s2相等
        System.out.println(s1.equals(s2));
        
        //.eauals()的方式比較是否相等
        //若比較不相等嘀韧,在比較的變量前加上!代表取反的意思
        
        //展示人的手機(jī)號
        //int 的取值范圍-2^31——2^31
        String v = "13599123456";
    }
}

數(shù)據(jù)類型轉(zhuǎn)換篇亭,裝箱,拆箱锄贷,強(qiáng)轉(zhuǎn)

package com.iteasyup.javase;

public class TestCollection {

    //包裝類:將基本數(shù)據(jù)類型定義為引用類型
    
    public static void main(String[] args) {
        
        //int的包裝類型
        Integer i = 100;
        //char的包裝類型
        Character c = 'a';
        
        //Byte Short Long Double Float Boolean
        
        //字符串與int之間的相互轉(zhuǎn)換
        int a= 10;
        //將整數(shù)類型轉(zhuǎn)換成字符串類型
        String s1 = String.valueOf(a);
        System.out.println(s1);
        
        String s2 = "123";
        //將字符串轉(zhuǎn)換成整數(shù)
        
        Integer i1 = Integer.valueOf(s2);
        //自動拆箱:引用類型轉(zhuǎn)換成基本類型
        int a1 = i1;
        
        //自動裝箱:基本數(shù)據(jù)類型變成引用類型
        int a2 = 100;
        Integer i2 = a2;
        //另一種裝箱方法
        int a3 = Integer.parseInt(s2);
        
        //強(qiáng)轉(zhuǎn):大類型轉(zhuǎn)小類型
    }
}

數(shù)組

package com.iteasyup.javase;

public class 數(shù)組 {

    public static void main(String[] args) {
        
        //定義一個整數(shù)類型的數(shù)組
        int[] arr = {2,45,1,5};
        arr[1] = 3;
//      System.out.println(arr[0]);
//      System.out.println(arr[1]);
//      System.out.println(arr[2]);
//      System.out.println(arr[3]);
        
        //利用循環(huán)的方式遍歷數(shù)組中的數(shù)據(jù)
        
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}

條件分支語句

package com.iteasyup.javase;

import java.util.Scanner;

public class 條件分支語句 {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        //如果輸入的成績大于60译蒂,輸出及格,否則輸出不及格
        System.out.println("請輸入學(xué)生成績:");
        double score = in.nextDouble();
        //if(條件:布爾表達(dá)式) {代碼執(zhí)行體}
//      if (score >= 60) {
//          System.err.println("及格");
//      } else {
//          System.out.println("不及格");
//      }
        
        if (score >= 90 && score <= 100) {
            System.out.println("優(yōu)秀");
        }else if (score >= 80 && score < 90) {
            System.out.println("良好");
        }else if (score >= 60 && score < 80) {
            System.out.println("及格");
        }else if (score >= 0 && score <60) {
            System.out.println("不及格");
        }else {
            System.out.println("成績必須在0-100之間");
        }
    }
}

通過流和反射來創(chuàng)建對象并調(diào)用一些私有化的變量和方法

package com.iteasyup.javase;

public class Student {

    int no;
    private int age;
    private String name;
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    private void show(String s1) {
        System.out.println(s1);
    }
}

package com.iteasyup.javase;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class TestStudent {

    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchFieldException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
        //創(chuàng)建對象
//      Student student = new Student();
//      student.setAge(20);
//      student.setName("小明");
//      System.out.println(student.getName());
//      System.out.println(student.getAge());
        
        //獲取到想要操作的這個類的字節(jié)碼
        
//      System.out.println(class1);
//      
////        Class<Student> class2 = (Class<Student>)new Student().getClass();   
//      
////        Class<Student> class3 = (Class<Student>) Class.forName("com.iteasyup.javase.Student");
//      
//      System.out.println(class1 == class2);
//      System.out.println(class2 == class3);
//      System.out.println(class1 == class3);
        
////        Class<Student> class1 = Student.class;
        //通過反射創(chuàng)建對象
        Student student = class1.newInstance();
        //獲取私有化的成員變量
        Field[] declaredFields = class1.getDeclaredFields();
        for (Field field : declaredFields) {
            System.out.println(field);
        }
        
        //獲取非私有化成員信息
        Field[] fields = class1.getFields();
        for (Field field2 : fields) {
            System.out.println(field2);
        }
        
        //獲取setname方法
        Method[] methods = class1.getMethods();
        
        for (Method method : methods) {
            System.out.println(method);
        }
        
        Method method = class1.getMethod("setName", String.class);
        method.invoke(student, "小紅");
        
        Method method2 = class1.getMethod("getName");
        System.out.println(method2.invoke(student));
        
        //執(zhí)行私有化的方法
        Method method3 = class1.getDeclaredMethod("show", String.class);
        method3.setAccessible(true);
        method3.invoke(student, "helloworld");
    }
}

同一個class中進(jìn)行方法調(diào)用

package com.iteasyup.javase;

public class TestMethod {

    public static void main(String[] args) {
        //1.輸出1-10的數(shù)字
        TestMethod.f1();
        //2.輸出1-10之間的偶數(shù)
        //3.輸出1-10之間的奇數(shù)
        //4.輸出1-10數(shù)字
        
        //方法的結(jié)構(gòu)
        //public訪問修飾符谊却,表示公開柔昼,任何人都可以調(diào)用,同理還有private炎辨,只能在當(dāng)前類下使用
        //static類訪問
        //void表示返回值類型
        //main表示方法的方法名
        //()里面稱之為參數(shù)
        //{}里面的東西就是方法的執(zhí)行體
    }
    //方法
    //static類調(diào)用
    public static void f1() {
        for (int i = 1; i < 11; i++) {
            System.out.println(i);
        }
    }
    
    public static void max(int c,int d) {
        //局部變量
        int a = c;
        int b = d;
        System.out.println(a > b ? a : b);
    }
}

文件基本操作

package com.iteasyup.javase;

import java.io.File;

public class TestFile {

    public static void main(String[] args) {
        
        //D:\\VS Code\\a.txt
        
        //D:\VS Code\a.txt
        File file = new File("D:/VS Code/a.txt");
        //獲取文件名字
        System.out.println(file.getName());
        //獲取文件的長度
        System.out.println(file.length());
        //文件是否存在
        System.out.println(file.exists());
        //獲取絕對路徑
        System.out.println(file.getAbsolutePath());
        //獲取相對路徑
        System.out.println(file.getPath());
        //刪除
//      System.out.println(file.delete());
        
        File file2 = new File("D:\\bb.txt");
        System.out.println(file2.getName());
        System.out.println(file.length());
    }
}

線程的兩種創(chuàng)建方式

package com.iteasyup.javase;

public class Customer1 implements Runnable {

    @Override
    public void run() {
        int money = 1000;
        for (int i = 0; i < 10; i++) {
            money -= 100;
            System.out.println("當(dāng)前賬戶余額:" + money);
        }
    }
}


package com.iteasyup.javase;

public class Customer2 extends Thread {

    @Override
    public void run() {
        int money = 1000;
        for (int i = 0; i < 10; i++) {
            money += 100;
            System.out.println("當(dāng)前賬戶余額:" + money);
        }
    }
}


package com.iteasyup.javase;

public class TestCustomer {

    public static void main(String[] args) {
        Runnable c1 = new Customer1();
        Thread c2 = new Customer2();
        
        Thread cc = new Thread(c1);
        cc.start();
        c2.start();
    }
}

有參構(gòu)造方法的使用

package com.iteasyup.javase;

public class Animal {
    
    //成員變量
    String name;
    int age;
    
    //構(gòu)造器:與類名同名捕透,并且沒有返回值類型的方法成為構(gòu)造方法
    //作用:①實(shí)例化(創(chuàng)建對象)②初始化成員變量(給成員變量賦值)
    
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void showAnimal() {
        System.out.println("動物的名字叫做" + name + "年齡為" + age + "歲");
    }
    
    public static void main(String[] args) {
        Animal animal = new Animal("小紅", 10);
        animal.showAnimal();
    }
}

有參構(gòu)造方法和無參構(gòu)造方法的使用的一個例子

package com.lingyige.javase;

public class Film {

    String filmName;
    String actorName;
    int money;
    
    public Film() {
        filmName = "這個殺手不太冷";
        actorName = "讓·雷諾";
        money = 0;
    }

    public Film(String filmName, String actorName, int money) {
        this.filmName = filmName;
        this.actorName = actorName;
        this.money = money;
    }
    public void addMoney(int day) {
        money += 300000 * day;
    }
    public void showFilm() {
        System.out.println(filmName + "這個電影很不錯,主演是:" + actorName + "碴萧,它的票房總額是:" + money);
    }
}

package com.lingyige.javase;

public class FilmTest {

    public static void main(String[] args) {
        Film f1 = new Film();
        f1.addMoney(9);
        f1.showFilm();
        
        Film f2 = new Film("這個手剎不太靈", "小強(qiáng)", 0);
        f2.addMoney(8);
        f2.showFilm();
    }
}

有參數(shù)的方法調(diào)用

package com.iteasyup.javase;

public class TestParameter {

    //需求:寫出一個方法表示用錢買了一瓶10元的水
    //求剩下多少錢                       //形參:形式上的參數(shù)

    public static void selectMoney(int money) {
        money -= 10;
        System.out.println("剩余" + money + "元");
    }
    
    public static void main(String[] args) {
        //在java中乙嘀,參數(shù)的傳遞方式是值傳遞,而不會關(guān)注變量名
        //實(shí)參:實(shí)際的參數(shù)
        int a = 100;
        selectMoney(a);     
    }
}

注意不要將有參無參構(gòu)造方法和方法混淆破喻,兩者的使用并不沖突

package com.lingyige.javase;
public class People {

    String name;
    int age;
    String sex;
    double height;
    
    public People() {
        name = "小剛";
        age = 24;
        sex = "男";
        height = 160.0;
    
    }
    
    public void talk(String t) {
        System.out.println(t + "說了一句受死吧");
    }
    
    public void changeName(String n) {
        name = n;
    }
    
    public void addHeight(double n) {
        height += n;
    }
    
    public void showPeople() {
        if (height >= 180) {
            System.out.println("他虎谢,身高" + height + "有余,孔武有力低缩,年僅" + age + "歲嘉冒,就以傲人的身高俯瞰眾生曹货,他就是" + name);
        }
        else {
            System.out.println("他,雖身高只有" + "height" + "讳推,卻有著驚人的速度和靈活性顶籽,年僅" + age + "歲,就能快速游走于公交人群中银觅,他就是" + name);
        }
    }
}

package com.lingyige.javase;
public class PeopleTest {

    public static void main(String[] args) {
        
        People people = new People();
        people.talk("大吉哥");
        people.changeName("vip");
        people.addHeight(180.0);
        people.showPeople();
        
    }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末礼饱,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子究驴,更是在濱河造成了極大的恐慌镊绪,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,826評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件洒忧,死亡現(xiàn)場離奇詭異蝴韭,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)熙侍,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,968評論 3 395
  • 文/潘曉璐 我一進(jìn)店門榄鉴,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人蛉抓,你說我怎么就攤上這事庆尘。” “怎么了巷送?”我有些...
    開封第一講書人閱讀 164,234評論 0 354
  • 文/不壞的土叔 我叫張陵驶忌,是天一觀的道長。 經(jīng)常有香客問我笑跛,道長付魔,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,562評論 1 293
  • 正文 為了忘掉前任堡牡,我火速辦了婚禮抒抬,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘晤柄。我一直安慰自己擦剑,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,611評論 6 392
  • 文/花漫 我一把揭開白布芥颈。 她就那樣靜靜地躺著惠勒,像睡著了一般。 火紅的嫁衣襯著肌膚如雪爬坑。 梳的紋絲不亂的頭發(fā)上纠屋,一...
    開封第一講書人閱讀 51,482評論 1 302
  • 那天,我揣著相機(jī)與錄音盾计,去河邊找鬼售担。 笑死赁遗,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,271評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼才菠,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了剖煌?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,166評論 0 276
  • 序言:老撾萬榮一對情侶失蹤逝淹,失蹤者是張志新(化名)和其女友劉穎耕姊,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體栅葡,經(jīng)...
    沈念sama閱讀 45,608評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡茉兰,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,814評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了妥畏。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片邦邦。...
    茶點(diǎn)故事閱讀 39,926評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖醉蚁,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情鬼店,我是刑警寧澤网棍,帶...
    沈念sama閱讀 35,644評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站妇智,受9級特大地震影響滥玷,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜巍棱,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,249評論 3 329
  • 文/蒙蒙 一惑畴、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧航徙,春花似錦如贷、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,866評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至窝稿,卻和暖如春楣富,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背伴榔。 一陣腳步聲響...
    開封第一講書人閱讀 32,991評論 1 269
  • 我被黑心中介騙來泰國打工纹蝴, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留庄萎,地道東北人。 一個月前我還...
    沈念sama閱讀 48,063評論 3 370
  • 正文 我出身青樓塘安,卻偏偏與公主長得像惨恭,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子耙旦,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,871評論 2 354