본문 바로가기

반응형

Programming/Java

(34)
3월 16일 생성자 D@101 주소 참조한 뒤 인덱스 번호만큼 메모리 연산하는 것. returnType nameOfMethod (Parameter List) { // method body } package day0316; public class ArrayTest13 { public static void main(String[] args) { int n; // stact double a; double[] num;//스택메모리 4바이트 할당,:heap메모리 참조하는 변수 num = new double[10]; //힙메모리에 할당 8*10 int[] num2; num2=new int[5]; System.out.println(num.length); System.out.println(num); System.out.println(nu..
2022년 3월 14일 배열 package arrays; import java.util.Scanner; public class ArrayTest03 { public static void main(String[] args) { int kor, eng, mat, tot; double avg; Scanner in = new Scanner(System.in); System.out.println("국어 : "); kor = in.nextInt(); System.out.println("영어 : "); eng = in.nextInt(); System.out.println("수학 : "); mat = in.nextInt(); in.close(); tot = kor+eng+mat; avg=(double)tot/3; System.out.println..
3월 12일 배운 것 package loop; public class DoWhileTest01 { public static void main(String[] args) { // do{} while(); // do는 일단 무조건 한 번 하고, while 문 조건에 따라서 한다. // 메뉴 구성할 때 등등 do { } while(false); } } package loop; import java.util.Scanner; public class DoWhileTest01 { public static void main(String[] args) { // do{} while(); // do는 일단 무조건 한 번 하고, while 문 조건에 따라서 한다. // 메뉴 구성할 때 등등 Scanner in = new Scanner(System..
Java Strings Tutorial package String; public class Main { public static void main(String[] args) { // two ways of initializing String String myString = new String("i love java"); String myString2 = "i love java"; if(myString.equals(myString2)) { System.out.println("strings are equal"); } System.out.println(myString.length()); System.out.println(myString.charAt(5)); System.out.println(myString.indexOf('o')); String st..
Java Regression problem I was trying to solve a regression problem from baekjoon algorithm., I was a little lazy studying these days, not because I am already good at it, but I met many people. I met two geniuses who are naturally smart enough to get the first status in their career. They were both younger than me but achieved so many competitive skills and philosophical thoughts. Even though they were younger, I calle..
Linked List linked list는 자료구조 중 하나인데, 저장할 수 있는 공간이 있으면, 다음 데이터 공간 주소를 함께 가지고 있는 구조이다. 배열과의 차이 배열은 정해진 공간이 있어서, 작업 중에 공간을 늘리거나 줄일 수가 없다. 그에 반해 linked list는 더하거나 빼는 것이 가능한데, 데이터 안에 그 위치 정보를 주는 것이다. 그런데 여기에서 새롭게 추가가 되었던 노드 정보를 끊고 다음 데이터로 연결을 시키게 되면, 아까 추가되었던 데이터를 부를 수 있는 방법이 사라졌기 때문에 사라진 것처럼 보이지만, 실제로는 메모리를 잡아먹고 있는 상태이다. C++과 같은 언어에서는 저 메모리를 삭제하겠다고 실제로 선언을 해줘야만 데이터가 사라지지만, 자바에서는 이러한 경우 자동적으로 삭제가 된다. 속도적으로는 데이터..
퀵 정렬 자바 퀵 정렬이라는 것은 작은 것은 왼쪽으로 큰 것은 오른쪽으로 분류를 하는 기법이다. 이렇게 두 개로 나눈 것을 파티션이라고 하는데, 파티션 안에서 또 파티션으로 쪼개면서 같은 기능을 반복하므로써 최종적으로 가장 작은 것부터 큰 것까지 정렬을 하게 된다. 퀵 정렬의 시간 복잡도는 O(n log n)으로 평균적으로 시간이 이 정도가 나온다는 뜻이다. 보통은 이것보다 빠르지만, 최악의 경우는 n2까지 나오기도 한다.
HashTable in java HashTable Hash Table is the most useful data structure for interview questions. for any problem, have hashtables at the top of your mind as a possible technique to solve problems. Key value lookup So this gives you a way of given a key, asscociating a value with it for quick lookups. String -> hashCode -> index - Array is often much smaller than the number of hashcodes

반응형