목록자바 (2)
100세까지 코딩

문제 class Parent { int x = 100; Parent() { this(500); // this() : 자기자신 객체 생성자 호출 } Parent(int x) { this.x = x; // this : 객체 자기자신을 의미 } int getX() { return x; } } class Child extends Parent { int x = 4000; Child() { this(5000); } Child(int x) { this.x = x; } } public class Main { public static void main(String[] args) { Child obj = new Child(); System.out.println(obj.getX()); } } 풀기 전 생각 정답은 100이라..

문제 설명 풀기 전 생각 말할 수 있는 단어를 배열에 넣기 babbling을 for문 돌면서 말할 수 있는 단어들이 포함되면 replace로 지우기 class Solution { public int solution(String[] babbling) { int answer = 0; String[] say = {"aya", "ye", "woo", "ma"}; // 말할 수 있는 단어들 for (int i = 0; i < babbling.length; i++) { //입력된 단어들 순회 for (int j = 0; j < say.length; j++) { if (babbling[i].contains(say[j])) { // 말할 수 있는 단어들 하나씩 검사 babbling[i] = babbling[i].rep..