이전글에서 non-static 블록을 알아보았고 이번글에서는 static 블록을 알아보겠습니다. static 블록은 non-static 블록 즉,{}에 static만 붙여준 것입니다. static{} 이런 형태입니다. 어떻게 사용되는지 살펴보면 class StaticBlock{ StaticBlock(){ System.out.println("Constructor called."); } static { System.out.println("Static Block called."); } } public class _118 { public static void main(String[] args) { StaticBlock b1 = new StaticBlock(); StaticBlock b2 = new StaticB..
자바 클래스에 그냥 {} 이렇게만 있는게 있습니다. 이것을 non-static 블록이라 합니다. 다음과 같은 형태가 non-static 블록입니다. class Block{ Block(){ System.out.println("Constructor called."); } { System.out.println("Block called"); } } public class _117 { public static void main(String[] args) { Block b1 = new Block(); Block b2 = new Block(); } } 결과 Block called. Constructor called. Block called. Constructor called. 그냥 클래스에 {} 이렇게만 있는게 no..
import java.util.Arrays; import java.util.List; public class StringArray { public static void main(String[] args) { 6:String[] names= {"Tom","Dick","Harray"}; 7:List list = names.asList() 8:list.set(0, "Sue"); 9:System.out.println(names[0]); } } What is the result of the following? A) Compiler error on line 8 B) Compiler error on line 7 C) Sue D) An exception is thrown. E) Tom 배열을 ArrayList로 변환할..
public class BirdSeed { private int numberBags; boolean call; public BirdSeed() { // LINE 1 call=false; // LINE 2 } public BirdSeed(int numberBags) { this.numberBags=numberBags; System.out.println("파리미터 생성자 호출됨"); } public static void main(String[] args) { BirdSeed seed = new BirdSeed(); System.out.println(seed.numberBags); } } Which code can be inserted to have the code print 2? A) Replace line..
Which of the following are true statements about the following code? (Choose all the apply) import java.util.ArrayList; import java.util.List; public class ListNull { public static void main(String[] args) { 4: List ages=new ArrayList(); 5: ages.add(Integer.parseInt("5")); 6: ages.add(Integer.valueOf("6")); 7: ages.add(7); 8: ages.add(null); 9: for(int age:ages) System.out.print(age); } } A) Exa..
이전글에서 자바로 naver papago 한글 영어 번역 api를 사용해서 번역이 되고 json 형식으로 리턴해주는것을 살펴보았다. 여기에 덧붙여서 json 형식으로 리턴되는것을 json-simple-1.1.1.jar 라이브러리를 사용해서 파싱하는것 까지 해보겠다. 우선 이전글에서 사용한 소스에다가 결과 찍는 다음줄에 JSONParser 부분을 추가하면 JSONParser jsonParser = new JSONParser(); JSONObject jsonObject = (JSONObject) jsonParser.parse(responseBody); System.out.println(jsonObject); JSONObject objMessage = (JSONObject) jsonObject.get("mes..
naver papago api를 사용해 자바 언어를 이용하여 번역 하는 방법을 알아보자. 어려운지 알았는데 설명보고 해보면 그리 어렵지도 않다. https://developers.naver.com/docs/papago/papago-nmt-example-code.md https://developers.naver.com/docs/papago/papago-nmt-example-code.md developers.naver.com developers.naver.com 을 가서 보면 샘플 코드에서 YOUR_CLIENT_ID 또는 YOUR-CLIENT-ID에는 애플리케이션을 등록하고 발급받은 클라이언트 아이디 값을 입력합니다. 샘플 코드에서 YOUR_CLIENT_SECRET 또는 YOUR-CLIENT-SECRET에는..
C# 등 마이크로소프트 관련 프로그램은 .exe 실행파일을 만들어 줘서 더블클릭하면 실행되지만 자바는 .exe가 없다. 그래도 .exe는 없지만 Runnable JAR file이 있어서 더블클릭으로 실행이 가능하다. 그럼 이클립스로 Runnable JAR file을 만드는 방법을 살펴보자. 이클립스 프로젝트에서 마우스 우클릭 후 Export를 선택한다. Java > Runnable JAR file 을 선택한다. Launch configuration은 프로젝트안의 여러 파일들 중에 메인으로 실행될 파일을 선택한다. Export destination은 말그대로 추출될 경로와 파일명을 지정한다. Finish 버튼 클릭. 그럼 해당 위치에 파일이 만들어 질 것이다. 그리고 그냥 jar 파일을 더블클릭 한다. 검..
방화벽이 열려있는지 안열려 있는지 체크 먼저하고 프로그램을 실행시키면 좋을것 같다. 안 그러면 .. 방화벽이 안 열려있다면 마냥 기다리다가.. 이유도 모른채 왜 안되지.. 할듯 그래서.. 방화벽 오픈 체크를 먼저 하고 오픈되었을때는 프로그램을 실행하고 아님 닫혀있다는 메시지를 사용자에게 전송하여 방화벽을 열게끔 하는게 맞겠지.. 그래서 방화벽 체크 소스를 한번 짜보면.. package test; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; import java.net.UnknownHostException; public class PortCh..
- Total
- Today
- Yesterday
- 파이썬
- esql
- XE
- Python
- proc
- XE3
- php
- 프로씨
- 라이믹스
- 자바
- KG
- xe애드온
- C
- ocajp
- 인포믹스
- MySQL
- JDBC
- EC
- 오라클
- 스크래핑
- ocjap
- 포인터
- 자바 smtp
- C언어
- 문자열
- 이클립스
- xe addon
- webix
- 플러터
- 파싱
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
