ajroot5685 / ajroot5685.github.io

MIT License
0 stars 0 forks source link

posts/final-%ED%82%A4%EC%9B%8C%EB%93%9C/ #6

Open utterances-bot opened 3 months ago

utterances-bot commented 3 months ago

자바의 final 키워드 | 안정적인 블로그

final 의미 기본적으로 final 키워드를 붙이면 해당 값을 변경할 수 없도록 동작한다. 즉, 단 한 번만 할당될 수 있는 Entity를 정의할 때 사용된다. final 키워드는 final 변수, final 메서드, final 클래스 총 3가지에 적용할 수 있다.

https://ajroot5685.github.io/posts/final-%ED%82%A4%EC%9B%8C%EB%93%9C/

hwanheejung commented 3 months ago

블로그가 예쁘네요~^^ 잘읽고 갑니다

mikio999 commented 3 months ago

Java의 static과 final은 무슨 차이가 있나요?

mingdodev commented 3 months ago

final을 사용하지 않으면 큰일이 날 수도 있을까요?

ajroot5685 commented 3 months ago

Java의 static과 final은 무슨 차이가 있나요?

@mikio999 final은 어떤 값이 변경되지 않도록 막는 키워드이고, static은 큰 범위(클래스 레벨)에서 값을 공유하기 위해 사용하는 키워드라고 생각하시면 됩니다.

static의 자세한 내용은 여기를 참고하세요~

ajroot5685 commented 3 months ago

final을 사용하지 않으면 큰일이 날 수도 있을까요?

@mingdodev

a 라는 값이 한번 설정된 후 변경되지 않는다. 라는 합의가 이루어졌을 때 final 을 사용하면 다음과 같은 상황을 방지할 수 있습니다.

hyunsoo121 commented 3 months ago

마지막 한줄 정리 너무 좋네요! 잘 읽고 갑니다~

solsoleee commented 3 months ago

안정적이네요