主頁 > 後端開發 > java 面向物件編程

java 面向物件編程

2021-03-06 06:27:53 後端開發

什么是面向物件

回顧方法的定義與呼叫

方法的定義

import java.io.IOException;

//Demo01 類
public class Demo01 {

    //main方法
    public static void main(String[] args) {

    }

    public String sayHello(){
        return "helloWorld";
    }
    
    public void readFile(String file) throws IOException{
        
    }

}

方法的呼叫

public class Demo02 {

    public static void main(String[] args) {

        //非靜態方法這樣
        new Student().say();

        //或者
        Student student=new Student();
        student.say();


    }

    //static 的方法是和類一起加載的,存在較早
    public static void a(){

        // b(); //這里會報錯,不能呼叫!!!!!!!

    }

    //類實體化之后才存在
    public void b(){

    }
}
//值傳遞
public class Demo03 {
    public static void main(String[] args) {

        int a=1;
        System.out.println(a);//1
        change(a);
        System.out.println(a);//1

    }

    //回傳值為空
    public static void change(int a){
        a=10;
    }

}
//參考傳遞: 傳遞的物件,本質還是值傳遞
//物件要理解透徹、記憶體要理解透徹!!!!!!!!
public class Demo04 {

    public static void main(String[] args) {

        Person person = new Person();
        System.out.println(person.name);//null
        change(person);
        System.out.println(person.name);//wda

    }

    public static void change(Person person){
        //person 是一個物件:指向的--》Person person = new Person(); 這是一個具體的人可以改變屬性
        person.name ="wda";
    }

}


//定義了一個Person類,有一個屬性
class Person{
    String name;//null
}

類與物件的創建

public class Student {

    //屬性;欄位
    String name;//null
    int age;//0

    //方法
    public void study(){
        System.out.println(this.name+"在學習");
    }



}

/*
public static void main(String[] args) {

        //類:抽象的,需要實體化
        //類實體化后會回傳一個自己的物件!
        Student xiaoming = new Student();
        Student xiaohong = new Student();

        xiaoming.age=3;
        xiaoming.name="ming";

        System.out.println(xiaoming.name);
        System.out.println(xiaoming.age);

    }
 */

構造器詳解

package com.oop.demo02;

//java-->會生成一個class檔案
public class Person {

    //一個類即使什么都不寫,也會存在一個方法
    //顯式的定義構造器
    String name;
    int age;

    //構造器的功能
    //實體化初始值
    //1.使用new關鍵字,本質是在呼叫構造器
    //2.用來初始化值
    public Person(){
        this.name="safa";

    }

    //有參構造器:一旦定義了有參構造,無參就必須顯式定義
    public Person(String name){
        this.name=name;
    }

    //alt+ insert 快捷定義構造器


}

/*
public static void main(String[] args) {

        //new 實體化了一個物件
        Person person = new Person("aaa");
        System.out.println(person.name); //aaa

    }
    構造器:
    1.和類名相同
    2.沒有回傳值
    作用:
    1.使用new關鍵字,本質是在呼叫構造器
    2.用來初始化值
    注意點:
    1.一旦定義了有參構造,如果想使用無參構造,無參就必須顯式定義
    alt+ insert 快捷定義構造器
    this.=
 */


創建物件記憶體分析

package com.oop.demo03;

public class Pet {
    public String  name;
    public int age;

    //無參構造

    public void shout(){
        System.out.println("叫了一聲");;
    }
}

/*
public static void main(String[] args) {
        Pet dog = new Pet();
        dog.name="wangcai";
        dog.age=3;
        dog.shout();

        System.out.println(dog.name);
        System.out.println(dog.age);

        Pet cat = new Pet();

    }
 */

封裝詳解

package com.oop.demo04;

//private 私有
public class Student {

    //封裝大多數時候是對屬性來說的,方法里面用的比較少
    /*
        1.提高程式的安全性
        2.隱藏代碼的實作細節
        3.統一介面
        4.系統可維護性增加了
    */

    // 名字
    //屬性私有
    private String name;

    //學號
    private int id;

    //性別
    private char sex;

    //年齡
    private int age;

    //提供一些可以操作這個屬性的方法
    //提供一些pubLicde的get、set方法

    //get 獲得這個資料

    public String getName(){
        return this.name;
    }

    //set 給這個資料設定值
    public void setName(String name){
        this.name=name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age>120||age<0){
            this.age = 3;
        }else {
            this.age=age;
        }

    }

    //學習()
    //睡覺()


}

/*
public static void main(String[] args) {
        Student s1 =new Student();
        // s1.name  會報錯

        s1.setName("sfa");
        s1.getName();

        //alt + insert 可以智能生成get set!!!!!!!!!!

        s1.setAge(999);//不合法的

        System.out.println(s1.getAge());

    }
 */

繼承

基礎

package com.oop;

import com.oop.demo05.Student;


public class Application {
    public static void main(String[] args) {
        Student student =new  Student();
        student.say();
        System.out.println(student.money);
        //System.out.println(student.money_private);
        //報錯,說明父類私有的屬性不能繼承
    }
}

package com.oop.demo05;

//在Java中,所有的類,都默認直接或間接繼承object類
//人 父類
public class Person /*extends Object*/{

    //public
    //protected
    //default
    //private
    public int money =10_0000_0000;

    private int money_private=10;

    public void say(){
        System.out.println("說了一句話");
    }

}

package com.oop.demo05;

//學生 is 人  派生類
//子類繼承了父類,就會擁有父類的全部方法!!!
public class Student extends Person{

    //ctrl+h  打開繼承樹!!!!!!

}

package com.oop.demo05;

//Teacher is Person  派生類
public class Teacher extends Person{
}

super詳解

package com.oop;

import com.oop.demo05.Student;


public class Application {
    public static void main(String[] args) {
        Student student =new  Student();
        //Person無參構造執行了
        //Student 無參執行了



        //student.test("aa");
        student.test1();
    }
}

package com.oop.demo05;

//在Java中,所有的類,都默認直接或間接繼承object類
//人 父類
public class Person /*extends Object*/{

    //public
    //protected
    //default
    //private
    public int money =10_0000_0000;

    private int money_private=10;

    protected String name="ks";

    //public-->private則出錯,私有的東西無法繼承
    public void print(){
        System.out.println("person");
    }

    public void say(){
        System.out.println("說了一句話");
    }

    public Person() {
        System.out.println("Person無參構造執行了");
    }
}

package com.oop.demo05;

//學生 is 人  派生類
//子類繼承了父類,就會擁有父類的全部方法!!!
public class Student extends Person{

    //ctrl+h  打開繼承樹!!!!!!
    private String name="qj";
    public void test(String name){
        System.out.println(name);//aa
        System.out.println(this.name);//qj
        System.out.println(super.name);//ks
    }

    public void print(){
        System.out.println("Student");
    }

    public void test1(){
        print();//Student
        this.print();//Student
        super.print();//person
    }

    public Student() {
        //隱藏代碼,默認呼叫了父類的無參構造!!!!!!!!!!
        super();//呼叫父類的構造器,必須要在子類構造器第一行
        System.out.println("Student 無參執行了");
    }
}

super注意點:
    1.super呼叫父類的構造方法,必須在構造方法的第一行
    2.super必須只能出現在子類的方法或者構造方法中!
    3.super和this不能同時呼叫構造方法

vs this:
    代表的物件不同:
        this:本身呼叫者這個物件
        super:代表父類物件的應用
    前提:
       this:沒有繼承也可以使用
       super:只能在繼承條件才可以使用
    構造方法
    this();本類的構造
    super();父類的構造

方法重寫

package com.oop.demo05;

//繼承
public class A extends B{
    @Override //注解:有功能的注釋
    public void test() {
        System.out.println("A->test()");
    }
}

package com.oop.demo05;

//重寫都是方法的重寫,和屬性無關
public class B {

    public void test(){
        System.out.println("B->test()");
    }
}

package com.oop;

import com.oop.demo05.A;
import com.oop.demo05.B;

public class Application {
    public static void main(String[] args) {

        //靜態的方法和非靜態的方法區別很大
        //靜態方法:方法的呼叫只和左邊,定義的資料型別有關
        //只有非靜態才叫做重寫 ,private也不可以,只有public才可以

        A a=new A();
        a.test();

        //父類的參考指向了子類
        B b=new A();//子類重寫了父類的方法
        b.test();

        //test()方法都有static時
        //A->test()
        //B->test()


        //靜態的方法和非靜態的方法區別很大
        //去掉static,即重寫之后
        //A->test()
        //A->test()


    }
}

重寫:需要有繼承關系,子類重寫父類的方法!
    1.方法名必須相同
    2.引數串列必須相同
    3.修飾符:范圍可以擴大:public>protected>default>private
    4.拋出的例外:范圍,可以被縮小,但不能擴大;classNotFoundException(xiao)-- Exception(da)是不可以的
重寫,子類的方法和父類必須要一致,方法體不同

為什么需要重寫:
    1.父類的功能,子類不一定需要,或者不一定滿足!
    快捷鍵: Alt+insert :override!!!!!!

多型

什么是多型

package com.oop;

import com.oop.demo06.Person;
import com.oop.demo06.Student;

public class Application {
    public static void main(String[] args) {

        //一個物件的實際型別是確定的
        //new Student();
        //new Person();

        //可以指向的參考型別就不確定了: 父類的參考指向子類

        //Student 能呼叫的方法都是自己的或者繼承父類的
        Student s1 = new Student();
        //Person 父型別,可以指向子類,但是不能呼叫子類獨有的方法
        Person s2 = new Student();
        Object s3 =new Student();

        s2.run();//son 子類重寫了父類的方法,執行子類的方法
        s1.run();//son

        //物件能執行哪些方法,主要看物件左邊的型別,和右邊關系不大
        // s2.eat(); 報錯
        ((Student)s2).eat();
        s1.eat();//eat


    }
}

package com.oop.demo06;

public class Student extends Person{
    @Override
    public void run() {
        System.out.println("son");
    }

    public void eat(){
        System.out.println("eat");
    }
}

/*
多型注意事項:!!!!!!!!!!!!!
1.多型是方法的多型,屬性沒有多型
2.父類和子類,有聯系  否則有型別轉換例外 ClassCastException
3.存在條件:繼承關系,方法需要重寫,父類參考指向子類物件 Father f1= new Son();

    1.static 方法,屬于類,它不屬于實體
    2.final 常量,不可以改變
    3.private 方法,私有的不能重寫
 */
package com.oop.demo06;

public class Person {

    public void run(){
        System.out.println("run");
    }

}

instanceof 和型別轉換

package com.oop;

import com.oop.demo06.Person;
import com.oop.demo06.Student;
import com.oop.demo06.Teacher;

public class Application {
    public static void main(String[] args) {
        //型別之間的轉換:父   子

        //高                   低
        Person obj=new Student();

        //student 將這個物件轉換為Student型別,就可以使用Student型別的方法了!

        ((Student) obj).go();

        //子類轉換為父類,可能丟失自己的本來的一些方法!
        Student student = new Student();
        student.go();
        Person person=student;
        //person.go();//報錯


    }
}

/*
1.父類參考指向子類的物件
2.把子類轉換為父類,向上轉型:
3.把父類轉換為子類,向下轉型:強制轉換
4.方便方法的呼叫,減少重復的代碼!簡潔!

抽象:封裝、繼承、多型! 抽象類,介面
 */
package com.oop.demo06;

public class Person {

    public void run(){
        System.out.println("run");
    }

}

package com.oop.demo06;

public class Student extends Person{

    public void go(){
        System.out.println("go");
    }

}

/*
//System.out.println(X instanceof  Y);//能不能編譯通過取決于是否有父子關系

        //Object>String
        //Object>Person>Teacher
        //Object>Person>Student
        Object object = new Student();
        System.out.println(object instanceof Student);//true
        System.out.println(object instanceof Person);//true
        System.out.println(object instanceof Object);//true
        System.out.println(object instanceof Teacher);//false
        System.out.println(object instanceof String);//false

        System.out.println("=============================");

        Person person =new Student();
        System.out.println(person instanceof Student);//true
        System.out.println(person instanceof Person);//true
        System.out.println(person instanceof Object);//true
        System.out.println(person instanceof Teacher);//false
        //System.out.println(person instanceof String);//編譯報錯

        System.out.println("=============================");
        Student student =new Student();
        System.out.println(student instanceof Student);//true
        System.out.println(student instanceof Person);//true
        System.out.println(student instanceof Object);//true
        //System.out.println(student instanceof Teacher);//編譯報錯
        //System.out.println(student instanceof String);//編譯報錯
 */
package com.oop.demo06;

public class Teacher extends Person{
}

static關鍵字

package com.oop.demo07;

public class Student {

    private static int age;//靜態變數 多執行緒中會仔細說到
    private double score;//非靜態變數

    public void run(){

    }

    public static void go(){

    }

    public static void main(String[] args) {
        Student s1 = new Student();

        System.out.println(Student.age);//建議通過這種型別來訪問靜態變數,靜態的變數對于類而言在記憶體中只有一個,可以被類中所有實體共享
//        System.out.println(Student.score);//報錯
        System.out.println(s1.age);
        System.out.println(s1.score);

//        Student.run();//報錯
        new Student().run();

        Student.go();
        go();//類中的的方法可以直接訪問類中的靜態方法

    }


}

package com.oop.demo07;

public final class Person {
    //被final修飾的類不能被繼承

    {
        //匿名代碼塊
        //程式執行時不能主動呼叫這個代碼塊
        //創建物件時自動創建,而且在構造器之前
        //可以用來賦初值
        System.out.println("匿名代碼塊");
    }

    static{
        //靜態代碼塊
        //類一加載就直接執行
        //永久執行一次
        System.out.println("靜態代碼塊");
    }

    public Person() {
        System.out.println("構造方法");
    }

    public static void main(String[] args) {

        Person person1=new Person();
        System.out.println("==============");
        Person person2=new Person();

        /*
        靜態代碼塊
        匿名代碼塊
        構造方法
        ==============
        匿名代碼塊
        構造方法
         */

    }
}

package com.oop.demo07;
//靜態匯入包
import static java.lang.Math.random;
import static java.lang.Math.PI;

public class Test {
    public static void main(String[] args) {
        System.out.println(random());
        System.out.println(PI);
    }
}

抽象類

package com.oop.demo08;

//抽象類  extends: 單繼承~ (介面可以實作多繼承)例如插座~
public abstract class Action {

    //約束~有人幫我們實作
    //抽象方法,只有方法名字,沒有方法的實作
    public abstract void doSomeThing();

    //1.不能new這個抽象類,只能靠子類去實作它;約束!
    //2.抽象類中可以寫普通方法
    //3.抽象方法必須在抽象類中
    //抽象的抽象:約束

    //思考題 不能new,存在構造器嗎?  存在!!!!↓↓↓↓↓↓↓↓
    //存在的意義是什么  抽象出來 提高開發效率


    public Action() {
    }
}

//抽象類的所有方法,繼承了它的子類,都必須實作這些方法~除非~它也是抽象類
public class A extends Action{

    @Override
    public void doSomeThing() {

    }
}

介面的定義與實作

package com.oop.demo09;


//抽象的思維~Java 架構師~
//interface 定義的關鍵字,介面都需要有實作類
public interface UserService {
    //介面中的所有定義的方法其實都是抽象的 默認為public abstract

    //屬性都是常量 默認 public static final
    int AGE=99;


    void add(String name);
    void delete(String name);
    void uodate(String name);
    void query(String name);

}

package com.oop.demo09;

public interface TimeService {
    void timer();
}

package com.oop.demo09;

//抽象類:extends
//類可以實作介面
//實作了介面的類,就需要重寫介面中的方法

//多繼承,利用介面實作多繼承
public class UserServiceImpl implements UserService,TimeService{

    @Override
    public void add(String name) {

    }

    @Override
    public void delete(String name) {

    }

    @Override
    public void uodate(String name) {

    }

    @Override
    public void query(String name) {

    }

    @Override
    public void timer() {

    }
}

作用:
    1.約束
    2.定義一些方法,讓不同的人實作~  10----》1
    3.方法都是 public abstract
    4.屬性都是 public static final
    5.介面不可以實體化~,介面中沒有構造方法
    6.implements可以實作多個介面
    7.必須重寫介面中的方法~

內部類

package com.oop;

import com.oop.demo10.Outer;

public class Application {
    public static void main(String[] args) {

        Outer outer = new Outer();

        //通過這個外部類來實體化內部類
        Outer.Inner inner = outer.new Inner();
        inner.getID();//10


    }
}

package com.oop.demo10;

public class Outer {

    private int id=10;
    public void out(){
        System.out.println("這是外部類的方法");

        //區域內部類
        class Inner{
            public void in(){

            }
        }


    }

    public class Inner{
        public void in(){
            System.out.println("這是內部類的方法");
        }

        //獲得外部類的私有屬性~
        public void getID(){

            System.out.println(id);

        }

    }

    //靜態內部類
    public static class Inner2{
        public void in(){
            System.out.println("這是內部類的方法");
        }

        //不能獲得外部類的屬性
        public void getID(){

//            System.out.println(id);//報錯

        }

    }


}

//一個Java類中可以由多個class類,但是只能由public class
class A{

}
package com.oop.demo10;

public class Test {
    public static void main(String[] args) {

        Apple apple = new Apple();

        //沒有名字初始化類,不用將實體保存在變數中
        new Apple().eat();

        //沒有名字初始化介面
        new UserService(){
            @Override
            public void hello() {

            }
        };
    }
}

class Apple{
    public void eat(){
        System.out.println("1");
    }
}

interface UserService{

    void hello();

}

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/266625.html

標籤:其他

上一篇:C語言進階丨(七)陣列的基本概念和初始化【1】

下一篇:Python內置庫:concurrent.confutures(簡單異步執行)

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more