개발 이론50 Java 기본 헷갈리는 문법(2) 메소드 체이닝 -메소드를 고리마냥 줄줄이 엵어서 메서드를 계속해서 사용하게끔 class People { private int height; private int weight; public int getHeight() { return height; } public void setHeight(int height) { this.height = height; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } } class ChainingPeople{ private int height; private int weight; public int getHeight() { return .. 2023. 3. 22. Java 기본 헷갈리는 문법(1) System.arraycopy System.arraycopy(oldstrArray,0,newStrArray,0,oldStrArray.length) ---> oldStrArray 인덱스 0에서부터 newStrArray 0에서부터 oldStrArray.length만큼 복사 return void run() { while(true) { if(gas>0) { System.out.println(gas); gas=1; }else { System.out.println(gas); return; } } while 뒤에 또 다른 메소드가 있다면 break;를 넣어야함 (return는 메소드 자체를 종료시킴) 정적메소드 인스턴스필드 + 인스턴스 메소드 + this(객체자신참조)키워드 사용불가 if 사용하고 싶다면 객체생성후 .. 2023. 3. 22. 이전 1 ··· 6 7 8 9 다음 728x90