java42 학원 수업 12일차 220902 9-10 상속 inheritance 메모리 어떻게 쓰는지? override? IS-A관계 10-11 Polymorphism 다형성 11-12 ex01, inheritance 코드 다시 따라쳐 [Tips] 이클립스(Eclipse) 하이라이트 설정 (코드 내 같은 단어 표시해주는 기능) 출처: https://dark0946.tistory.com/111 우클릭 > Source > override override vs overloading 구분해 override 전제조건 : 상속관계 부모의 바디를 수정해서 나타낸 것 @ 어노테이션 다형적 표현이 무슨 말..? PolymorphismTest02.java CC cc=new CC(); //이건 알겠는데 cc.disp(); AA ac=new CC(); //이건 앞이 왜.. 2022. 10. 6. 학원 수업 11일차 220901 11-12 입출력스트림 FileOutputStream try - catch - finally FileOutputStream fos= new FileOutputStream(fileName, true); //true : 덮어쓰기X, 기존데이터 + 추가데이터 저장 12-1 ObjectOutputStream Classes that require special handling during the serialization and deserialization process must implement special methods with these exact signatures: 직렬화..? public class LottoDTO implements Serializable 2-3 for(: 배열){} 향상된 for문(.. 2022. 10. 6. 학원 수업 10일차 220831 9-10 빌더 패턴? 10-11 상속 Package Explorer > ... > Package Presentation > Hierarchical 패키지 하위 생성가능 com.green.kdt public int x; protected int y; int z; private int m; public 전부 접근 가능 protected 같은 패키지 안에서만 접근 가능 but 다른 패키지여도 상속이 되어있으면 가능 package (생략시 package) 동일 패키지가 아니므로 접근 불가 private final 선언과 동시에 초기화해야함 가장 많이 쓰는 건 public, private package com.green.kdt; import com.green.nowon.Nowon; public class Nowo.. 2022. 10. 5. 자바 반복문을 이용한 구구단 출력(while, do while, for) //2단 출력 System.out.printf("2 * %d = %d\n", 1, 2*1); System.out.printf("2 * %d = %d\n", 2, 2*2); System.out.printf("2 * %d = %d\n", 3, 2*3); 한줄한줄 칠 필요 없이 int i=1; System.out.println("2단"); while(i 2022. 10. 5. 자바 반복문 while, do while, for 기본 문법 Java - Loop Control 반복문의 3요소 (초기값, 조건문, 증감문) 초기값에 증감문을 더하여 조건문이 참인 횟수만큼 statements가 실행됩니다 반복문 세가지 while, do while, for를 차례로 살펴보자 while 문법Syntax while(Boolean_expression) { // Statements } A while loop statement in Java programming language repeatedly executes a target statement as long as a given condition is true. Boolean_expression이 '참'이면 Statements가 실행됩니다. 거짓일때까지 반복! 기본 예제 public class LoopTe.. 2022. 9. 30. 자바 void? void void는 메서드 선언시 쓰이는 단어로 리턴되는 타입이 없음을 의미! public static void main(String[] args) { } return : 결과값을 돌려주는 명령어 리턴되는 타입이 있을 때는? 메서드 선언시 리턴하려는 데이터의 타입을 써주고 바디에서 반드시 해당하는 타입에 맞는 값을 반환해야 함 //getters and setters public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; public static .. 2022. 9. 30. 학원 수업 9일차 220830 9-10 메서드 https://www.tutorialspoint.com/java/java_methods.htm 지역변수 인스턴스변수 클래스변수 main메서드 안에서 쓰는 변수 : 지역변수 (stack메모리에 만들어짐) 10-11 void? return 되는 타입이 없음 return != break return 실행하고 나서 보고받는 것 2022.09.30 - [JAVA] - 자바 void? private 접근제한 public 접근 제한이 없습니다. 11-12 getter메서드 : 필드의 정보를 읽어올 수 있는 기능 수행 static? 객체를 만들 필요 없음(인스턴트화 노필요) 클래스이름. 으로 바로 접근 생성자 무조건 1개이상 존재 안보이면? 디폴트 값으로 안보이는 상태로 존재 다른 클래스에 있는 메서드.. 2022. 9. 30. IF, Switch 조건문 가위바위보 조건문을 다양하게 사용하여 구현해보는 가위바위보 import java.util.Scanner; public class IfTest02 { public static void main(String[] args) { //com, user //가위:0, 바위:1, 보:2 int user; Scanner sc=new Scanner(System.in); System.out.println("가위:0, 바위:1, 보:2"); System.out.print("뭘 내볼까? 숫자로 입력해봐! : "); user=sc.nextInt(); //if (user==0) { //System.out.println("나는 가위!"); //} else if (user==1) { //System.out.println("나는 바위!"); /.. 2022. 9. 30. 자바 조건문 If, Else, Else if, Switch 기본 문법, 간단한 예제 If 조건문 기본 문법 if(조건식) { 실행문; } 기본 예제 import java.util.Scanner; public class IfTest01 { public static void main(String[] args) { //변수를 선언하면 지역변수local variable int num; //int를 입력받을 때는 nextInt 메서드를 이용한다. Scanner scanner=new Scanner(System.in); //인스턴스 System.out.println("숫자입력 : "); num=scanner.nextInt(); if(num%2==0) { //조건문이 true일때 실행되는 영역 System.out.println(num+"은 짝수!"); } //조건이 false인 경우 if(num%2=.. 2022. 9. 29. 이전 1 2 3 4 5 다음