Notepad 로고 이미지Notepad

menu-opener icon
  • 홈
  • 방명록
  • 관리자
Kotlin static 이용 Companion Object 포스팅 썸네일 이미지

Kotlin/Syntax

Kotlin static 이용 Companion Object

1. static 역할 - Companion Object 기존 Java에서 사용하였던 static은 Kotlin에서는 존재하지 않는다. 하지만 Companion Object를 사용한다면 static 역할을 해낼 수 있다. 여기서 중요한 점은 static의 역할을 할 수 있다는 것이지 static인것은 아니다. class Book private constructor(var name: String) { companion object { var count: Int = 0 private set fun create(name:String) : Book { count++ return Book(name) } fun print() = println("$count") } } fun main() { Book.print() ..

2020.10.03 게시됨

1
300x250

Profile

    Email: notepad1029@gmail.com

    Github: https://github.com/Notepad96

최근글

인기글

태그 클라우드

  • Android
  • Android kotlin DB
  • 쿠버
  • Android kotlin
  • android viewbinding
  • Kotlin
  • android simpledateformat
  • kotlin for
  • c++ stl
  • android floating button
  • android 이중 리사이클러뷰
  • android kotlin calendar
  • kubernetes
  • android border
  • terraform azure
  • android kotlin recyclerview
  • kotlin sort
  • android 이미지 불러오기
  • Terraform
  • android kotlin intent
  • android 테두리
  • android registerForActivityResult
  • C++
  • c++ algorithm
  • android corner
  • android api
  • android layout divid
  • Kotlin android
  • Algorithm
  • android kotlin room
Copyright . 베이스캠프 all rights reserved.
Designed by 베이스캠프
닫기 아이콘
사이드 프로필 배경이미지
블로그 이미지

Notepad96

IT, 코딩, 등 지식을 저장하고 편하게 볼 수 있도록 만든 메모장

  • 분류 전체보기 (195)
    • Android (86)
      • TIP (21)
    • Cloud (4)
    • C++ (49)
      • Algorithm (11)
      • Container (13)
      • STL (24)
    • Figma (1)
    • Kotlin (49)
      • Algorithm (8)
      • Syntax (13)
      • Collections (28)
    • Kubernetes (3)
    • Terraform (3)
Designed by 베이스캠프

티스토리툴바