티스토리 뷰

PS/PS_Note

[Java] PS Coding Tip(~ing)

Aaron 2020. 7. 21. 23:45
반응형


.입출력


.입출력

- BufferedReader

1
2
3
4
5
6
7
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());    // int
String str = br.readLine();    // string
 
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken()); 
int M = Integer.parseInt(st.nextToken()); 
cs


- Scanner

1
2
3
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();    // int
String str = sc.next();    // string
cs


- 배열 원소 확인(Test)

1
System.out.println(Arrays.toString(chk));
cs


--

--

--


.자료형


.String to Char

1
char motion[] = br.readLine().toCharArray();
cs



.Object Sort

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public static class Student implements Comparable<Student>{
    int mid,finals,assign,index;
    int score;
    public Student(int mid,int finals,int assign,int index){
        this.mid = mid;
        this.finals = finals;
        this.assign = assign;
        this.index = index;
        score =mid*35 + finals*45 + assign*20;
    }
 
    @Override
    public int compareTo(Student o) {
        return score - o.score;
    }
}
cs


.2차원 ArrayList

1
2
3
4
ArrayList<Integer> nodes[] = new ArrayList[N];
 
for (int i = 0; i < N; i++
        nodes[i] = new ArrayList<Integer>();
cs


.Iterator

1
2
3
4
5
6
7
public void printPatientList() {
    Iterator<Patient> itr = patientList.iterator();
    while(itr.hasNext()){
        Patient p = itr.next();
        System.out.println(p);          
    }
}
cs



.메모리


.배열 메모리 초기화

1
Arrays.fill(chk, 0);
cs






--

--

--


.

--

--

--

--


.

--

--

--

--


반응형
댓글
최근에 올라온 글
최근에 달린 댓글
링크
Total
Today
Yesterday