java.lang은 기본적인 자바의 기본구성요소이다.
여기에는 Object, Class, String, Exception, Thread, Math, System, Runtime 외
Boolean, Byte, Short, Integer, Long, Float, Double등이 래퍼클래스가 포함되어있다.
https://standout.tistory.com/1193
java.lang패키지
java.lang패키지 자바프로그래밍에 가장 기본이 되는 클래스와 인터페이스를 포함하는 패키지이다. 여기에는 Object, Class, String, Exception, Thread, Math, System, Runtime 외 Boolean, Byte, Short, Integer, Long, Float, D
standout.tistory.com
패키지에 등록된 클래스들을 살펴보자.
모든 클래스의 최고 조상인 Object클래스
https://standout.tistory.com/1195
java.lang패키지 : Object 클래스
Object 클래스 Object 클래스는 모든 클래스의 최고 조상이다. 대표적으로 equals(), hashCode(), clone()이 사용된다. https://standout.tistory.com/191 true인지 false인지, equals() equals() true인지 false인지 출력해 확인
standout.tistory.com
문자열 관련된 String클래스
https://standout.tistory.com/1196
java.lang패키지 : String 클래스
타 언어에서 문자열을 char형의 배열로 다루나 자바에서는 문자열을 위한 클래스를 제공한다. 문자열 관련 메서드는 방대하며 아래는 자주 사용될것들으로 이해한다. 물론 이도 양이 상당하다. S
standout.tistory.com
문자열 관련 메소드는 외로도 join(), java.util.StringJoiner클래스가있다.
https://standout.tistory.com/1197
문자열배열을 합칠 수 있는 join()
join() 여러 문자열 사이에 구분자를 넣어서 결합한다. split()과 반대의 작업을 한다고 이해하자. // 예시 2: 문자열 배열을 join String[] fruits = {"Apple", "Banana", "Orange"}; String result2 = String.join(", ", fruits);
standout.tistory.com
https://standout.tistory.com/1198
문자열배열을 합칠 수 있는 java.util.StringJoiner
StringJoiner 여러 문자열 사이에 구분자를 넣어서 결합한다. split()과 반대의 작업을 한다고 이해하자. // 문자열 결합을 위한 StringJoiner 생성 StringJoiner joiner = new StringJoiner(", ", "[", "]"); // 문자열 추
standout.tistory.com
형식화된 문자열을 만들어내는 방법에는 format()이 있으며 이러한 이론은 JSTL 태그라이브러리에서도 확인 할 수 있다.
https://standout.tistory.com/164
문자열 포맷 형식 format(%/)을 이용한, 환율계산기
format("%", 변수) format은 문자열 사이사이에 %로 형식값을 지정해 변수를 삽입해 출력하기 좋다. 예를들어, 아래와 같은 변수 3개를 큰따옴표 ""로 묶인 깔끔한 한줄로 출력할 수 있다는 소리다. Stri
standout.tistory.com
https://standout.tistory.com/549
fmt:formatNumber, 쉽게 금액표현하기
상단에 fmt를 정의하고, 금액에 들어가는 곳을 fmt태그로 감싸 패턴을 지정한다.
standout.tistory.com
String 클래스 외로 비슷하지만 StringBuffer클래스와 StringBuilder클래스가 있다.
정리하자면 String 클래스는 불변성시 사용되고,
StringBuffer과 StrinfBuilder는 동적으로 사용되나 Builder의 경우 안전성을 보장하지않는다.
https://standout.tistory.com/1199
String, StringBuffer, StringBuilder 클래스의 차이
String 클래스 한번 생성된 문자열은 변경 불가능하다. 문자열 조작이 빈번한 경우에은 새로운 문자열이 게속 생성되어 성능에 영향을 끼칠 수 있다. 안전성을 보장한다. 문자열 상수, 문자열 연
standout.tistory.com
https://standout.tistory.com/1201
StringBuilder란? : StringBuffer와의 차이
StringBuffer는 멀티쓰레드에 안전하도록 동기화되어있다. 우선 이 동기화는 성능을 떨어뜨리는것만 이해해보면 되는데, 멀티쓰레드로 작성된 프로그램이 아닌경우 불필요하게 성능만 떨어뜨린다
standout.tistory.com
https://standout.tistory.com/1200
java.lang패키지 : StringBuffer 클래스
StringBuffer StringBuffer는 String클래스와 유사한 메서드를 많이 가지고 있다. 여기서 추가, 변경, 삭제와 같이 변경할 수 있는 메서드들이 추가로 제공된다.
standout.tistory.com
Math 클래스
javascript에도 해당 기능이 있어 익숙할텐데, 마찬가지로 기본적인 수학계산에 유용한 메서드로 구성되어있는 클래스이다.
https://standout.tistory.com/613
Math.min/max 최소값, 최대값 구하기
최소값, 최대값 구하기 Math.min.apply Math.max.apply let array2 = [273, 52, 103, 57, 271]; let min=Number.MIN_VALUE; let max=Number.MAX_VALUE; min= Math.min.apply(null, array2); max= Math.max.apply(null, array2); document.write(`가장 작은 수${
standout.tistory.com
wrapper 클래스
자바의 기본형을 제공한다.
https://standout.tistory.com/131
Wrapper, 기본 자료형을 제공하는 클래스
Wrapper 기본 자료형(bsil fd cb)의 객체를 제공하는 클래스 https://standout.tistory.com/56 자바 기본타입 (bsilfdcb) 외워보자. bsil fd cb 비실한 fd가 시비를 건다. 자바에서 값을 표현할때 데이터 타입으로 정
standout.tistory.com
외에 유용한 클래스에는 아래와 같다.
Objects 클래스
Objects 클래스는 추가된 클래스로 객체 관련 메서드들을 제공한다.
https://standout.tistory.com/1212
Object클래스를 보완하다, java.util.Objects 클래스
Objects 클래스 Objects 클래스는 추가된 클래스로 객체 관련 메서드들을 제공한다. 기존 Object클래스를 보완하는 역할을 하는데 이에는 객체의 비교, 해시코드생성, null체크 등이 있다. https://standout.
standout.tistory.com
Math.random()은 간단히 0.0~1.0의 난수를 생성하지만
java.util.Random 클래스는 더많은 유연성과 다양한 형태의 난수를 생성할 수 있다
https://standout.tistory.com/1213
java.util.Random 클래스
random()하면 수학용 Math클래스에서의 random메소드가 있다. https://standout.tistory.com/1207 수학계산 메서드 모음집, Math클래스 Math클래스 Math클래스는 접근 제어자가 private이기에 다른클래스에서 Math 인
standout.tistory.com
정규식 클래스
원래 Unix에서 사용하던 Perl의 강력한 기능이었으나 요즘은 다양한 언어제서 지원.
java.util.regex.Pattern에 기호와 작성방법이 설명되어있으나 그 양이 방대함.
https://standout.tistory.com/1214
java.util.regex 정규식 패키지
정규표현식 regular expression, 간단히 regexp 또는 regex, rational expression) 또는 정규식이라 불림. https://standout.tistory.com/73 코드를 줄여주는 정규표현식 정규표현식 regular expression, 간단히 regexp 또는 regex,
standout.tistory.com
Scanner 클래스
https://standout.tistory.com/1215
java.util.Scanner 입력소스를 읽다
Scanner는 화면, 파일, 문자열과 같은 입력소스로부터 문자데이터를 읽어온다. 각 생성자는 특정한 유형의 데이터소스에 적합하도록 설계되어있으니 우선 가볍게 읽어보며 참고하자. Scanner (String
standout.tistory.com
java.util.StringTokenizer
긴 문자열을 지정된 구분자를 기준으로 token이라 불리는 여러개의 문자열로 잘라냄
https://standout.tistory.com/1216
String.split()의 구식 api, java.util.StringTokenizer
java.util.StringTokenizer 긴 문자열을 지정된 구분자를 기준으로 token이라 불리는 여러개의 문자열로 잘라냄 split나 useDelimiter를 사용할 수도있다. String input = "apple,orange,banana"; String[] fruits = input.split(",
standout.tistory.com
java.math.BigInteger , long보다 큰 정수값을 계산할때
java.math.BigDecimal, double타입보다 오차가 없도록 2진수로 변환해 수를 다룬다.
https://standout.tistory.com/1217
java.math.BigInteger long보다 큰 정수값을 계산할때
정수는 값의 한계가 있다. 과학적 계산에서 더 큰값을 다뤄야할때 사용하는것이 BigInteger, 다만 성능은 long타입보다 떨어질 수 밖에 없다. https://standout.tistory.com/22 숫자의 종류, 실수 무리수 유리
standout.tistory.com
https://standout.tistory.com/1218
java.math.BigDecimal, double타입보다 오차가 없도록 2진수로 변환해 수를 다루다
double타입으로 표현할 수 있는 값은 범위가 넓으나 정밀도가 최대 13자리밖에 되지않아 오차를 피할 수 없다. https://standout.tistory.com/22 숫자의 종류, 실수 무리수 유리수 정수 자연수 간단히 예시
standout.tistory.com
https://standout.tistory.com/1219
BigInteger과 BigDecimal의 차이
BigInteger 정수를 나타내기 위한 클래스, 양의정수 및 음의 정수를 표현할 수 있다. https://standout.tistory.com/1217 java.math.BigInteger long보다 큰 정수값을 계산할때 정수는 값의 한계가 있다. 과학적 계산
standout.tistory.com
'이론' 카테고리의 다른 글
OpenHub 오픈허브란? (0) | 2024.01.08 |
---|---|
하루가 더 많다, 윤년 (0) | 2023.12.27 |
BigInteger과 BigDecimal의 차이 (0) | 2023.12.26 |
java.util.regex 정규식 패키지 (0) | 2023.12.26 |
AutoBoxing 오토박싱과 Unboxing 언박싱 (0) | 2023.12.22 |