1. ๋๋ฒ๊น ์ ๋ฌธ๊ตฌ์ ๋ณ์ ๊ฐ์ด ์ถ๋ ฅํ๊ณ ์ถ์๋
System.out.printf("๋น๊ต๋ฌธ ์ถ๋ ฅ %d < %d || %d < %d",a,b,c,d);
System.out.printf("๋ฌธ์์ด ์ถ๋ ฅ %s",e);
2. ์ต์๊ฐ, ์ต๋๊ฐ ๊ตฌํ ๋
int min = Integer.MAX_VALUE;
while (true) {
...
min = Math.min(min, origin[currentX][currentY]);
...
}
return min;
3. ๋ฐฐ์ด ์ถ๋ ฅํ ๋
import java.util.Arrays;
// 1์ฐจ์ ๋ฐฐ์ด
System.out.println(Arrays.toString(arr));
// 2์ฐจ์ ๋ฐฐ์ด
System.out.println(Arrays.deepToString(arr));
4. hashmap ๊ด๋ จ
import java.util.HashMap;
static HashMap<String, String> relationMaps = new HashMap<String, String>();
static HashMap<String, Integer> payMaps = new HashMap<String, Integer>();
static HashMap<String, ArrayList<String>> listMaps = new HashMap<String, ArrayList<String>>();
// ๋ฐ์ดํฐ ์ถ๊ฐ
for (int i = 0; i < enrolls.length; i++) {
relationMaps.put(enrolls[i], referrals[i]);
}
// ๋ฐ์ดํฐ ์์
payMaps.replace(seller, payMaps.get(seller) + sellerPaid);
5. string for loop
String s = "blog";
// charAt
for (int i = 0; i < s.length(); i++) {
System.out.print(s.charAt(i));
}
// toCharArray
char[] chars = s.toCharArray();
for (char ch: chars) {
System.out.print(ch);
}
6. stringbuilder
StringBuilder sb = new StringBuilder();
sb.append("1 ").append("2");
// string ์ถ๋ ฅ
String str = sb.toString();
7. stack
Stack<Integer> stack = new Stack<>();
stack.push(1); // push
stack.pop(); // pop
stack.size(); // size
stack.get(i); // index ๋ฆฌํด
๋ฐ์ํ
'๐ค ์๊ณ ๋ฆฌ์ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
baekjoon. ๋ฌธ์์ด ํญ๋ฐ (0) | 2022.08.29 |
---|---|
programmers. ๋ค๋จ๊ณ ์นซ์ ํ๋งค (0) | 2022.06.29 |
programmers. ํ๋ ฌ ํ ๋๋ฆฌ ํ์ ํ๊ธฐ (0) | 2022.06.26 |
programmers. ๋ก๋์ ์ต๊ณ ์์์ ์ต์ ์์ (0) | 2022.06.23 |
ํด์ปค๋ญํฌ. Sorting: Bubble Sort (java) (0) | 2022.03.26 |