Java 상수

개요[ | ]

자바에서 변하지 않는 상수를 선언하여 코드의 유지보수를 쉽게 할수 있다
예를 들면 IP 주소 혹은 경로 등등
public class ConstantsTest{

    public static final String	ANSIBLE_IP	= "127.0.0.1";
    public static final String ANSIBLE_PORT	= "2222";

    public static void main(String[] args) throws Exception{

        String ansibleIP= ANSIBLE_IP.toString();
        String ansiblePort = ANSIBLE_PORT.toString();

        System.out.println(ansibleIP);
        System.out.println(ansiblePort);
    }

}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}