๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

[Java] isNumeric(String s) ๋ฉ”์†Œ๋“œ

public static boolean isNumeric(String s) { try { Double.parseDouble(s); return true; } catch(NumberFormatException e) { return false; } } String s ; boolean chk = isNumeric( s );

๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

[Java] ArrayList ์‚ฌ์šฉ๋ฒ•

ArrayList๋ž€? ArrayList๋Š” List ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ƒ์†๋ฐ›์€ ํด๋ž˜์Šค๋กœ ํฌ๊ธฐ๊ฐ€ ๊ฐ€๋ณ€์ ์œผ๋กœ ๋ณ€ํ•˜๋Š” ์„ ํ˜•๋ฆฌ์ŠคํŠธ์ž…๋‹ˆ๋‹ค. 1. ํ•œ๋ฒˆ ์ƒ์„ฑ๋˜๋ฉด ํฌ๊ธฐ๊ฐ€ ๋ณ€ํ•˜์ง€ ์•Š๋Š” ๋ฐฐ์—ด๊ณผ๋Š” ๋‹ฌ๋ฆฌ ArrayList๋Š” ๊ฐ์ฒด๋“ค์ด ์ถ”๊ฐ€๋˜์–ด ์ €์žฅ ์šฉ๋Ÿ‰(capacity)์„ ์ดˆ๊ณผํ•œ๋‹ค๋ฉด ์ž๋™์œผ๋กœ ๋ถ€์กฑํ•œ ํฌ๊ธฐ๋งŒํผ ์ €์žฅ ์šฉ๋Ÿ‰(capacity)์ด ๋Š˜์–ด๋‚œ๋‹ค๋Š” ํŠน์ง•์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ArrayList ์„ ์–ธ import java.util.ArrayList; ArrayList list = new ArrayList();//ํƒ€์ž… ๋ฏธ์„ค์ • Object๋กœ ์„ ์–ธ๋œ๋‹ค. ArrayList members = new ArrayList();//ํƒ€์ž…์„ค์ • Student๊ฐ์ฒด๋งŒ ์‚ฌ์šฉ๊ฐ€๋Šฅ ArrayList num = new ArrayList();//ํƒ€์ž…์„ค์ • intํƒ€์ž…๋งŒ ์‚ฌ์šฉ..

๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

[Java] ์‹คํ–‰ ์‹œ๊ฐ„ ๊ตฌํ•˜๊ธฐ

long start = System.currentTimeMillis(); //์ฝ”๋“œ ์‹คํ–‰ ์ „์— ์‹œ๊ฐ„ ๋ฐ›์•„์˜ค๊ธฐ //์‹คํ—˜ํ•  ์ฝ”๋“œ ์ถ”๊ฐ€ long end = System.currentTimeMillis(); // ์ฝ”๋“œ ์‹คํ–‰ ํ›„์— ์‹œ๊ฐ„ ๋ฐ›์•„์˜ค๊ธฐ System.out.println("์‹œ๊ฐ„์ฐจ์ด(m) : "+ (end-start)/1000 ); [์ถœ์ฒ˜ : hijuworld.tistory.com/2 ]

๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

[Java] ์Šคํƒ(Stack) / ํ(Queue) ์ •๋ฆฌ

Queue Queue queue = new ArrayDeque(); Queue queue = new LinkedList(); Queue๋Š” Interface์ด๊ธฐ ๋•Œ๋ฌธ์—, ์œ„์™€๊ฐ™์ด ํ•ด๋‹น ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ํด๋ž˜์Šค๋กœ ์ƒ์„ฑํ•˜์—ฌ, ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋ก ์ ์œผ๋กœ๋Š” ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ์˜ ํŠน์„ฑ์„ ๊ฐ–๋Š” LinekdList๊ฐ€ ํšจ์œจ์ด ์ข‹์•„์•ผ ํ•˜์ง€๋งŒ, ์‹ค์ œ๋กœ๋Š” ์—ฌ๋Ÿฌ ์ด์œ ๋•Œ๋ฌธ์— ArrayDeque์ด ์†๋„๊ฐ€ ์กฐ๊ธˆ ๋” ๋น ๋ฅด๋‹ค๊ณ  ํ•œ๋‹ค. ์–ด์ฐจํ”ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ๋‚ด์—์„œ ํฐ ์ฐจ์ด๋Š” ์—†์„ ๊ฒƒ ๊ฐ™์œผ๋‹ˆ ์•„๋ฌด๊ฑฐ๋‚˜ ์“ฐ์ž. LinkedList qu = new LinkedList();//ํ์˜ ์ƒ์„ฑ //DeQue qu = new ArrayDeque(); //add()๋ฉ”์†Œ๋“œ๋ฅผ ์ด์šฉํ•œ ์ €์žฅ qu.add("๋„ท"); qu.add("๋‘˜"); qu.add("์…‹")..

๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

[Java] 10์ง„์ˆ˜ -> 2์ง„์ˆ˜

Integer.toBinaryString( int i ); return : String int a = 30; String b = Integer.toBinaryString( a ); a : 30 b : 0001 1110 Integer.parseInt( String s , int n์ง„์ˆ˜ ); return : int String s = Integer.toBinaryString( a ); // 0001 1110 int i = Integer.parseInt( s , 2 ); s : 0001 1110 i : 30

๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ

[Java] ๋น„ํŠธ์—ฐ์‚ฐ์ž ( & , | ,..)

101010101011 0์œผ๋กœ. | ์—ฐ์‚ฐ์ž // |์—ฐ์‚ฐ์ž ( or ) int a = 7; int b = 15; int c = a | b; a : 0111 b : 1111 ----or์—ฐ์‚ฐ----- c : 1111 or ์—ฐ์‚ฐ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค. ๋‘˜์ค‘ ํ•˜๋‚˜๋ผ๋„ 1์ด๋ฉด 1์ด๋‹ค. ( 1 or 0 = 1, 0 or 1 = 1 ) &์—ฐ์‚ฐ์ž // &์—ฐ์‚ฐ์ž(and) int a = 7; int b = 15; int c = a&b; a : 0111 b : 1111 ----&์—ฐ์‚ฐ------ c : 0111 and ์—ฐ์‚ฐ์ด๋‹ค. ๋‘˜ ๋‹ค 1์ด๋ฉด ๊ฒฐ๊ณผ๊ฐ’์ด 1์ด๋‹ค. ( 1 and 0 = 0 , 1 and 1 = 1) ^์—ฐ์‚ฐ์ž // ^์—ฐ์‚ฐ์ž( XOR ) int a = 7; int b = 15; int c = a ^ b; a : 0111..

iseunghan
'๐ŸŒป JAVA/์ •๋ฆฌ์ •๋ฆฌ์ •๋ฆฌ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (6 Page)