1st seminar : 기본과제#1
Conversation
jiyeoon00
left a comment
There was a problem hiding this comment.
정리가 아주 꼼꼼하군요ㅎ 개념이랑 코드랑 같이 볼 수 있어서 보기 좋네요!
| // 문자열 리터럴이 생성될 때마다 JVM은 해당 문자열이 string constant pool에 존재하는지 확인 | ||
| // 있으면, 상수 풀에 저장된 기존 문자열을 쓰고 | ||
| // 없으면, 상수풀에 새로 저장한다. | ||
| // ! 이때 다른 리터럴 타입(int, bool..) 과 문자열 리터럴은 저장 위치가 다르다 ! 다른 리터럴타입은 일시적으로 스택에 저장됨 |
There was a problem hiding this comment.
여기 헷갈려서 찾아본 부분인데 아주 말끔하게 정리해놨네!.!
| System.out.println(System.identityHashCode(test3)); //1798286609 | ||
|
|
||
|
|
||
| // equals 메소드와 '==' 연산자의 차이 |
There was a problem hiding this comment.
이거 프젝 진행할 때 정말 사소한데 삽질하기 쉬운 부분이라고 생각하는데, 정리 넘 깔끔하네요! 저도 참고해서 정리해놓겠숩니다ㅎㅎ🙇♀️
There was a problem hiding this comment.
[P5] 진짜 이건 몰랐네,,! Object의 equals 메소드는 값을 비교하는게 아니라 주소를 비교하는구나!
There was a problem hiding this comment.
저도 값이 아니라 주소를 비교한다는 것 ...!!!! 알아갑니다..!!
| Integer ih = genericClass.genericMethod3(i,new String(), new Double(11.1)); | ||
| System.out.println(ih); | ||
|
|
||
| //Integer ij = genericClass.genericMethod3(new ArrayList(),i, new Object()); //컴파일 에러 |
There was a problem hiding this comment.
이렇게 보니까 제네릭의 장점인 컴파일 시에 미리 타입 검사를 할 수 있다는게 확 와닿는다,,🙂
| // 1. 사용 목적 | ||
| // : 인터페이스는 구체적인 로직이나 상태를 가지고 있을 수 없고, 추상클래스는 추상메소드 이외에 구체적인 로직이나 상태를 가지고 있기에 | ||
| // 추상클래스는 기능을 확장시키는데 초점, 인터페이스는 함수의 구현만을 강제 | ||
| // 2. 추상화정도 : 인터페이스가 추상화정도가 훨씬 높다. 추상클래스는 구체적인로직과 구현을 가질수 았가 때문 |
There was a problem hiding this comment.
[P5] 인터페이스는 함수의 구현을 강제하고 추상클래스는 기능을 확장하는게 목적이라고만 정리하고 넘어갔었는데, 추상화정도에도 차이점이 있다고 하니까 뭔가 더 와닿는다!
ddongseop
left a comment
There was a problem hiding this comment.
진짜 엄청나게 꼼꼼하다.. 덕분에 모르고 넘어갈뻔한 개념도 알게되구 완전 자극받고 갑니다!!
| public void age(){ | ||
| age++; | ||
| } |
There was a problem hiding this comment.
age()라는 메소드를 다른 곳에서 볼 때 이 메서드가 무슨 용도인지 알기 힘들 수 있다고 생각해요. 수화님 생각은 어떠신가요?
There was a problem hiding this comment.
addAge() 등이 더 좋을것같아요!
| public String getSpecies(){ | ||
| return this.species; | ||
| } | ||
|
|
||
| public String getName(){ | ||
| return this.name; | ||
| } |
There was a problem hiding this comment.
| public String getSpecies(){ | |
| return this.species; | |
| } | |
| public String getName(){ | |
| return this.name; | |
| } | |
| public String getSpecies(){ | |
| return species; | |
| } | |
| public String getName(){ | |
| return name; | |
| } |
추천합니다.
| private String species; | ||
| private String name; | ||
| private int age; |
There was a problem hiding this comment.
생성자의 인자로 age, name, species가 들어가는데, 필드의 순서는 조금 다른 것 같아요! 순서를 맞춰보는 것은 어떠신가요?
| private String gender; | ||
| private boolean isMarried; | ||
|
|
||
| public Person(int age, String name, String species,String gender, boolean isMarried){ |
There was a problem hiding this comment.
| public Person(int age, String name, String species,String gender, boolean isMarried){ | |
| public Person(int age, String name, String species, String gender, boolean isMarried){ |
| return type1; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
헐 너무 꼼꼼하게 정리 잘한다...너무 수고했어..!!
| System.out.println(System.identityHashCode(test3)); //1798286609 | ||
|
|
||
|
|
||
| // equals 메소드와 '==' 연산자의 차이 |
There was a problem hiding this comment.
저도 값이 아니라 주소를 비교한다는 것 ...!!!! 알아갑니다..!!
1주차 세미나의 기본과제입니다.
객체지향 원리를 코드로 만들었습니다.
팟장님 코드 + 내 개인 코드 인듯요?