๐ ๊ณต๋ถํ๋ ์ง์ง์ํ์นด๋ ์ฒ์์ด์ง?
[JAVA ์ฝ๋ฉ ์ด๋ณด] Stack (๋ฆฌ์คํธ) Method ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
<๋ณธ ๋ธ๋ก๊ทธ๋ codechacha ๋์ ๋ธ๋ก๊ทธ๋ฅผ ์ฐธ๊ณ ํด์ ๊ณต๋ถํ๋ฉฐ ์์ฑํ์์ต๋๋ค :-)>
๐ Stack Method
๐ ์์ ์ถ๊ฐ & ์ ๊ฑฐ & ๋น์ฐ๊ธฐ & ์ ๋ฌด ํ์ธ
import java.util.*;
import java.io.*;
// tip: each public class is put in its own file
public class main
{
// tip: arguments are passed via the field below this editor
public static void main(String[] args)
{
ArrayList<Integer> list = new ArrayList<>(Arrays.asList(0, 3, 2, 1, 5));
System.out.println(list); // [0, 3, 2, 1, 5]
//์ ์ํ List ์์ ์ค ์ต๋, ์ต์๊ฐ
System.out.println(Collections.max(list));
System.out.println(Collections.min(list));
//List ์ ๋ ฌ
Collections.sort(list); // ์ค๋ฆ์ฐจ์ (ASC)
System.out.println(list);
Collections.sort(list, Collections.reverseOrder()); // ๋ด๋ฆผ์ฐจ์ (DESC)
System.out.println(list);
//List ๋ค์ง๊ธฐ
Collections.reverse(list);
System.out.println(list);
//List ๋ด ์์์ ๊ฐฏ์ ๋ฐํ
System.out.println(Collections.frequency(list, 3));
}
}
728x90
๋ฐ์ํ
'๐ฆฅ ์ฝํ > JAVA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA ์ฝ๋ฉ ์ด๋ณด] Queue (ํ) Method (0) | 2023.07.16 |
---|---|
[JAVA ์ฝ๋ฉ ์ด๋ณด] List (๋ฆฌ์คํธ) Method (0) | 2023.07.16 |
[JAVA ์ฝ๋ฉ ์ด๋ณด] StringBuilder(์คํธ๋ง๋น๋) Method (0) | 2023.07.16 |
[JAVA ์ฝ๋ฉ ์ด๋ณด] String(์คํธ๋ง) Method (0) | 2023.07.16 |
[JAVA ์ฝ๋ฉ ์ด๋ณด] ๋ฐฐ์ด ์ ๋ ฌ (์ค๋ฆ์ฐจ์, ๋ด๋ฆผ์ฐจ์) (0) | 2023.07.16 |
Comments