Java (13) 썸네일형 리스트형 5. JAVA 클래스 학습할 것 클래스 정의하는 방법 객체 만드는 방법 (new 키워드 이해하기) 메소드 정의하는 방법 생성자 정의하는 방법 this 키워드 이해하기 클래스란? 객체를 정의해놓은 것. 또는 객체의 설계도 객체(인스턴스)란? 클래스에 정의된 내용대로 메모리에 생성된 것 클래스 정의하는 방법 public class Tv { //Tv의 속성(멤버변수) String color; boolean power; int channel; //Tv의 기능(메서드) void power(){} void channelUp(){} void channelDown(){} } 객체 만드는 방법 Tv tv = new Tv(); 연산자 new에 의해 Tv클래스의 인스턴스가 메모리의 빈 공간에 생성된다. 그 다음 생성된 객체의 주소값이 참조변수 .. 섹션10. Inheritance and Polymorphism Inheritance Classes that share common fields should inherit from a parent class. Use super() to call the parent constructor from the child class. Use super.method to call a parent method from the child class. Interface: contract of behaviour. Classes that implement an interface must override every method inside of it. Polymorphism: an object can take its form or the class it inherits from. an ob.. Unit 8~9 Cheat sheet Array vs. ArrayList vs. HashMap Array fixed. stores primitives and objects. type[] values = new type[] ArrayList resizable. stores objects. ArrayList values = new ArrayList(); HashMap resizable. stores key-value pairs. HashMap pairs = new HashMap() Rule: use arrays when size is fixed (less overhead). Use ArrayList when size can vary. Use HashMap when there is parity between data. HashMap vs. Tre.. 섹션9. Unit Testing, Stream API & Lambda Unit Test download the Junit Jar file VSCODE에서 Ctrl + Shift + P - settings.json 열기 "java.project.referencedLibraries": [ "lib/**/*.jar", "D:\\프로그래밍\\java\\junit-platform-console-standalone-1.8.0-M1.jar" ] Test-Driven Development. Writing test before writing code 모듈화가 되어있어야 좋은 코드 otherwise, 테스트가 어렵고, 버그에 취약함, not scalable Good code is easy to test Identify meaningful test cases. Test Cases ------.. 섹션8. Exception handling and debugging Debugging Continue: continues to the next breakpoint. Step over: steps over a line (see Debugging Exercise 3). Step into: steps into a function/cons. Step out: steps out of a function/cons. Restart: restarts the runtime. Stop: stops the runtime launch json ~~~ 위와 같이 breakpoint(빨간 점) 체크하고 - lanch current file 실행 then you can visualize each variable in the left pane Debugger not working? 1. Create.. 섹션7. Objects Object Oriented Programming - Find closely related variables - Combine them into an object Car audi = new Car(variable1, 2, 3...); audi.drive(); Car hyundai = new Car(variable1, 2, 3...); hyundai .drive(); How to plan your code - Look for objects(things) - Look for fields that describe each object - Look for actions the object can perform java creats an object of the car class *object = instance.. 섹션5~6. Loops & Arrays For Loops - 몇 번 반복할지 미리 정함 for (int i=1; i= 3){ System.out.println("wow"); }else{ System.out.println("lose"); } } break and continue - continue : skips a run and continues to the next one public static void main(String[] args) { for (int i = 0; i = 3; i--) { moreItems[i] = items[i]; } System.out.println(Arrays.toString(moreItems)); 결과) [null, null, null, chair, oven, phone] 6.4 Reference Trap Ar.. 섹션4. Function public static void name(int param) { } void : return value 없음 static : main함수에서 실행하려면 있어야 함 Function Parts Level of access: private, public. Return type: double, int, boolean, char, String, long. Function name: lowerCamelCase (singChorus, kickBall). Parameter: value received by the function. Argument: value passed into the function. Code: performs your task. return breaks the entire function. No.. 이전 1 2 다음