java 체인 호출

김효준·2023년 11월 7일
0

수업정리

목록 보기
9/41
package com.ll;

public class Main {
    public static void main(String[] args) {
        Article article = new Article();

        Article article_ = article.setTitle("Hello, World!");
        article_.setWriterName("Paul");
    }
}

class Article {
    private String title;
    private String writerName;

    public String getTitle() {
        return title;
    }

    public Article setTitle(String title) {
        this.title = title;

        return this;
    }

    public String getWriterName() {
        return writerName;
    }

    public void setWriterName(String writerName) {
        this.writerName = writerName;
    }
}

0개의 댓글