java35 자바 메모리 구조 1. 메모리 - 프로그램을 실행하기 위한 데이터 및 명령어를 저장하는 공간 * 메모리구조를 공부하는 이유 - 같은 기능의 프로그램이더라도 메모리 관리에 따라 성능이 좌우됨. - 메모리 관리가 되지 않은 경우 속도저하 현상이나 튕김 현상 등이 일어날 수 있음. - 한정된 메모리를 효율적으로 사용하여 최고의 성능을 내기 위함. 2. 자바 프로그램의 실행구조 - 프로그램이 실행되기 위해서는 windows나 linux같은 운영체제(OS)가 제어하고 있는 시스템의 리소스의 일부인 메모 리(RAM : 주기억장치)를 제어할수 있어야 한다. - java이전의 c같은 대부분의 언어로 만들어진 프로그램은 이러한 이유때문에 OS에 종속되어 실행되게 되어 있었다. - java프로그램은 JVM(Java Virtual Machi.. 2022. 10. 9. Spring IoC IoC = inversion of control : 제어권의 역전 일반적인 경우 의존성에 대한 제어권을 자기 자신이 가진다. 의존관계는 간단히 말해 new 라는 키워드를 통해 생성된다. public class Sample { private Samsung samsung = new Samsung(); } 의존성 역전(Inversion of Control) -Ioc란 inversion of Control의 약어로, 객체의 의존성을 역전시켜 객체 간의 결합도를 줄이고 유연한 코드를 작성 하게하여 가독성 및 코드의 중복, 유지보수를 편하게 할 수 있게 한다. SampleTest 라는 클래스에서 Samsung 객체를 생성한뒤 Sample 클래스의 생성자로 주입시켜준다. 여기서 Sample이 직접 Samsung을 생.. 2022. 10. 9. DI(Dependency Injection) DI(Dependency Injection) - 스프링이 다른 프레임워크와 차별화되어 제공하는 의존 관계 주입 기능으로 객체를 직접 생성하는 게 아니라 외부에서 생성한 후 주입 시켜주는 방식이다. DI(의존성 주입)을 통해서 모듈 간의 결합도가 낮아지고 유연성이 높아진다. 방법1 ex) class Dogs{ private String DogName; private int DogAge; public Dogs(){ } public Dogs(String DogName, int DogAge){ this.DogName = DogName; this.DogAge = DogAge; } public String getDogName(){ return this.DogName; } public int getDogAge(){ .. 2022. 10. 9. 제네릭스 타입 컴파일 Generics type erasure 제네릭스(Generics)란? - 데이터 타입을 일반화(Generalize)하는 것을 의미 - 다양한 타입의 객체들을 다루는 메소드나 컬렉션 클래스에 컴파일 시의 타입 체크를 해주는 기능 제네릭스를 사용하는 이유 - 클래스나 메소드 내부에서 사용되는 객체의 안정성을 높일 수 있다. - 반환값에 대한 타입 변환 및 타입 검사에 들어가는 노력을 줄일 수 있다. 제네릭스의 형식 public class 클래스명 {...} public interface 인터페이스명 {...} == Type == Element == Key == Value == Number == Result Java Generics Type Erasure(제네릭 타입소거) 구체화 vs 비구체화 구체화 타입(reifiable type) : 자신의 타.. 2022. 10. 8. Memo api 구현 최대한 lombok 없이 구현해 보았다. Memo.java @Entity public class Memo extends Timestamped{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(nullable = false) private String username; @Column(nullable = false) private String contents; // 파라미터가 있는 생성자를 하나라도 정의하게 되면 // 더이상 기본생성자를 생성하지 않기때문에 기본생성자를 꼭 만들어줘야한다. // @NoArgsConstructor 을 사용하는 이유 public Memo(){ } public Memo(MemoRequestDt.. 2022. 10. 7. @RestController A convenience annotation that is itself annotated with @Controller and @ResponseBody. Types that carry this annotation are treated as controllers where @RequestMapping methods assume @ResponseBody semantics by default. @Controller 및 @ResponseBody로 자체 주석이 달린 편리한 주석. 이 주석을 포함하는 유형은 @RequestMapping 메서드가 기본적으로 @ResponseBody 의미 체계를 띠고 있는 컨트롤러로 처리됩니다. @RestController를 입은 컨트롤러는 요청 매핑 애노테이션을 붙인 메서드의 리턴으.. 2022. 10. 6. @GetMapping Annotation for mapping HTTP GET requests onto specific handler methods. Specifically, @GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET). HTTP GET 요청을 특정 처리기 메서드에 매핑하기 위한 주석입니다. 특히 @GetMapping은 @RequestMapping(method = RequestMethod.GET)의 바로 가기 역할을 하는 합성 주석입니다. 2022. 10. 6. Spring 서버에서 객체를 JSON으로 변환 후 응답하기 JSON 응답 클라이언트는 서버를 거쳐서 DB에 접근한다. 클라이언트가 DB에서 필요한 정보를 얻기 위해, 서버에게 데이터를 요청하면 서버에서는 클라이언트가 필요한 데이터 또는 그 데이터가 포함된 데이터를 보내준다. 이 때, 서버가 보내주는 데이터는 클라이언트가 해석하기 쉬우면 좋고, 내용이 간결해서 전송속도가 빠르면 좋을 것입니다. 그래서 사용하는 데이터의 형식 중 대표적인 하나가 JSON입니다. Jackson 라이브러리 는 JAVA Object 형태의 값을 데이터 구조를 표현하는 방식인 XML 또는 JSON 형태로 만들어 보낼때 사용하는 라이브러리다. Jackson 라이브러리 특징 - XML/YAML/CSV 등 다양한 형식의 데이터를 지원 - 스트림 방식으로 속도가 빠르며 유연하고, annotatio.. 2022. 10. 6. isAlphabetic() Determines if the specified character (Unicode code point) is an alphabet. A character is considered to be alphabetic if its general category type, provided by getType(codePoint), is any of the following: or it has contributory property Other_Alphabetic as defined by the Unicode Standard. Params: codePoint – the character (Unicode code point) to be tested. Returns: true if the character is a Uni.. 2022. 9. 28. indexOf() Params: ch – a character (Unicode code point). //유니코드 Returns: the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur. 파라미터 : ch - 문자 리턴값 : 객체에 해당하는 문자열에 첫번째로 존재하는 문자의 인덱스 또는 해당하는 문자가 없으면 -1을 리턴 public int indexOf(int ch) { return indexOf(ch, 0); } 2022. 9. 27. valueOf() Returns the string representation of the {@code char} array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the returned string. param : data - the character array. // 매개변수 문자배열 return : a {@code String} that contains the characters of the character array. //문자배열의 문자들로 구성된 문자열 public static String valueOf(char data[]) //문자 .. 2022. 9. 27. toCharArray() //반환타입이 char[] 문자 배열 //문자열을 조각내서 문자배열 안에 넣어줌 public char[] toCharArray() { return isLatin1() ? StringLatin1.toChars(value) : StringUTF16.toChars(value); } Params:format – A format string args – Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero.. 2022. 9. 27. 이전 1 2 3 다음