Develop/Java

Develop/Java

[Java] The value of the local variable is not used 문제 해결

코드를 작성하다보면 The value of the local variable is not used 라는 경고가 뜰 것이다. 아래 코드를 같이 보자. package sec01.exam04; public class VariableScopeExample { public static void main(String[] args) { int v1 = 15; if(v1>10) { int v2; v2 = v1 - 10; } } } 우리는 위 코드를 쳐보면 8번째줄에서 The value of the local variable v2 is not used 라는 오류가 발생할 것이다. 에러는 아니라 실행은 되겠지만 경고라니 먼가 찜찜하다. 이러한 경고는 선언한 변수 v2는 사용되지 않고 할당만 되므로 경고가 표시되는 것이다...

JuniTech
'Develop/Java' 카테고리의 글 목록