본문 바로가기

Programming/Java, Spring98

[Java 기초문법] Exceptions 자바 예외 처리 [Java 기초문법] by Professional Java Developer Career Starter: Java Foundations @ Udemy Exceptions Any time something can go pretty wrong in your program, an exception can be, what we call, thrown, meaning an exception can occur. 3 types : 1) checked Exceptions 2) unchecked Exceptions 3) errors Files.lines 와 같이 java.util에서 내재적으로 exception을 일으키도록 구현된 클래스/메소드들도 있다. 예외를 처리하는 가장 단순한 방법 package com.neutr.. 2022. 10. 20.
[Java 기초문법] Streams API | Streams, stream의 다양한 메소드, sum, sort, filter [Java 기초문법] by Professional Java Developer Career Starter: Java Foundations @ Udemy Streams 이와 같은 텍스트를 가져올 때 streams of strings으로 가져오는 것을 보자. forEach => Consumer라고 하는 functional interface를 입력하도록 요구 peopleText.lines() .forEach(System.out::println); 하나씩 가져오는 것을 볼 수 있다. what's happening here is that this line's method is returning a stream of strings, which are the individual line, each string is b.. 2022. 10. 20.
[Java 기초문법] collections, list, linked list, looping with iterators [Java 기초문법] by Professional Java Developer Career Starter: Java Foundations @ Udemy Collections 자바에서 Collections은 object를 store하는 형식을 말한다. List, Set, Queue, Deque로 구분되고 별도로 Map이 존재한다. Colletions의 특징은 dynamic 변경이 가능하다는 점이다. And also the entire collecionts API of Java is heavily predicated on the use and knowledge of interfaces. Lists Lists are intended to allow us to store objects in order. List .. 2022. 10. 20.
[Java 기초문법] 자바 람다 Lambdas, delegate method [Java 기초문법] by Professional Java Developer Career Starter: Java Foundations @ Udemy Lambdas public static final Employee createEmployee(String employeeText){ Matcher peopleMat = Employee.PEOPLE_PAT.matcher(employeeText); if (peopleMat.find()) { return switch (peopleMat.group("role")){ case "Programmer" -> new Programmer(employeeText); case "Manager" -> new Manager(employeeText); case "Analyst" -.. 2022. 10. 20.
[Java 기초문법] 자바 records [Java 기초문법] by Professional Java Developer Career Starter: Java Foundations @ Udemy 자바 프로그래머라면 일반적으로 시작할 때 fields를 추가하고 1개의 constructor와 getters and setters를 각각 깔고 시작을 하는 경향이 있다. 그렇다면 왜 이런 starting point가 필요한가에 대한 의문이 생겨난다. import java.time.LocalDate; import java.util.Objects; public class Weirdo { private String lastname; private String firstname; private LocalDate dob; public Weirdo() { } publ.. 2022. 10. 20.