java
-
[Java] javac, java 명령어java/Java Command 2022. 11. 20. 20:57
https://docs.oracle.com/en/java/javase/11/tools/javac.html#GUID-AEEC9F07-CB49-4E96-8BC7-BCC2C7F725C9 Tools Reference You can use the javac tool and its options to read Java class and interface definitions and compile them into bytecode and class files. docs.oracle.com IDE를 쓰다보니, classpath에 대한 이해가 부족하였으며, 프로젝트 구조에 대한 지식도 부족함을 느껴서 직접 컴파일과 실행작업을 진행해보기로 하였는데, 진행도중 -classpath(-cp)옵션, -sourcepath옵션, 패..
-
[Java] String 문자열 splitjava 2022. 11. 1. 14:07
String의 split메서드에 대해서는 대강 써봤지만 정확한 동작과 깊게는 써보지 못한 상태여서 정리한글 split메서드 결과 배열 출력을 위한 클래스 package string.split; public class PrintUtil { public static void printStringArray(String[] results) { System.out.println("string array length: " + results.length); System.out.println(); for (String item : results) { System.out.println("item 출력"); System.out.println(item); System.out.println("length(): " + item..
-
[Java] Mac주소 Hex String 변환java 2022. 10. 28. 09:22
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/NetworkInterface.html#getHardwareAddress() NetworkInterface (Java SE 11 & JDK 11 ) Get an Enumeration with all or a subset of the InetAddresses bound to this network interface. If there is a security manager, its checkConnect method is called for each InetAddress. Only InetAddresses where the checkConnect doesn't throw a Secur..
-
[Java] String.formatjava 2022. 9. 7. 15:44
public class CshMain { public static void main(String[] args) { // 1. %d : 10진수 정수 포맷 stringFormatTest(String.format("%d", 1)); stringFormatTest(String.format("abc%dabc", 1)); // %05d // %0의 0 : 채워질 문자 // %05의 5 : 총 5자리를 만듬 stringFormatTest(String.format("%05d", 1)); // 5(전체자릿수) - 1(1표현자릿수) -> 좌측 네 자리를 0으로 채움 stringFormatTest(String.format("%05d", 12)); // 5(전체자릿수) - 2(12표현자릿수) -> 좌측 세 자리를 0으로 채..
-
[Java] Comparator,Comparable구현시 주의할 점java 2022. 7. 13. 11:04
https://st-lab.tistory.com/243 자바 [JAVA] - Comparable 과 Comparator의 이해 아마 이 글을 찾아 오신 분들 대개는 Comparable과 Comparator의 차이가 무엇인지 모르거나 궁금해서 찾아오셨을 것이다. 사실 알고보면 두 개는 그렇게 어렵지 않으나 아무래도 자바를 학습하면서 객 st-lab.tistory.com overflow, underflow 고려하여 메서드 구현 필요
-
Generic 총정리java/Generic 2022. 7. 2. 03:59
1. Generic 클래스의 타입 변수에 대입될 수 있는 것들 primitive 타입(int,long,double,float ....등등)이 아닌 모든 것 primitive배열 타입 //int[] , double[] ... 참조 타입 배열 //String[], Integer[] ... 인터페이스 타입 클래스 타입 2. Generic 클래스의 상속 관계 class Box {} Object와 String은 조상 자손 관계라서 다형성이 적용되지만 Box import java.util.ArrayList; public class NoWildcardProblem { public static void main(String[] args) { ArrayList stringArrayList = new ArrayList()..
-
[Thread] InterruptedException과 인터럽트 상태java/Thread 2022. 6. 12. 16:18
스레드의 인터럽트 메카니즘과 인터럽트 상태에 대하여 정리했다. 인터럽트라는 단어에서 뭔가 중단하다.방해하다라는 느낌이 애매해서 이해하기 어려웠던 것 같다. 특정 스레드에 인터럽트를 건다라는 의미 = 스레드가 일시정지 상태인 경우 또는 일시정지에 들어가려는 스레드인 경우 쉬지 못 하게 하는 기능이다. 스레드 인터럽트 메카니즘을 이해하기 위해 아래의 개념들을 보자. -- 스레드 인터럽트 플래그(상태) 스레드의 인터럽트 상태는 인터럽트 예외(InterruptedException)와 연관있는 플래그이다. // 1. thread변수에 해당하는 스레드의 인터럽트 상태를 체크한다.(인터럽트 상태를 변경하지 않고 확인만 한다) thread변수.isInterrupted(); // 2. 현재 스레드의 인터럽트 상태를 리턴..