Java/java.lang.Object 4

String 에 대한 고찰

String 객체 타입은 Java 언어에서 특혜를 심하게 받고 있는 객체이다. 그만큼 사용 빈도가 많다는 말씀.. ■ Java 문서에서의 정의 The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. ..

== equals 무엇이 다른 것인가 ??

이것만 기억하자. == : 7가지 Primitive type (byte, short, int, long, float, double, boolean, char) 에만 사용한다고 기억하자. equals : 모든 객체의 비교에는 equals 만 사용한다고 기억하자. == ( 동일성 identity - 오브젝트를 참조하는 위치(주소)가 같을 경우 ) equals ( 동등성 equality - 해당 인스턴스가 가지고 있는 값이 같을 경우 ) 뭔가 더 심오한 뭔가를 적어서 유레카를 외치고 싶은데.. 더 할말이 없네... 원시타입 7종은 은 == 객체는 equals 끝... 완전 좋은 참고 영상 : https://www.youtube.com/watch?v=6X1jsQQtwmo

java.lang.Object 의 위치(Position)

Object 클래스는 모든 클래스의 최 상위에 위치하며, 모든 클래스에서 상속받는 클래스이다. 따라서, Object 클래스의 주요 method 를 익히는것은 중요한 포인트가 된다. (equals, hashCode, toString) The Java Platform Class Hierarchy The Object class, defined in the java.lang package, defines and implements behavior common to all classes—including the ones that you write. In the Java platform, many classes derive directly from Object, other classes derive from som..

Object class , 숨겨진 최상위 객체

질문에 앞서 - 프로그램을 만들때 모든 객체는 해당 클래스가 존재해야 하며, 해당 클래스를 사용하기 위해서는 반드시 해당 클래스를 import 한 후 new 를 통해 생성해야 한다. 질문 - 그렇다면, String , int 등 주로 사용하는 객체들은 왜 new 로 객체생성을 하지 않아도 사용이 되는 것인가? 질문의동기 - 사실 이 질문은 Spring beans 의 DI 를 공부하다가 궁금하여서 찾아보게 되었다. 답변 : java.lang.Objec 클래스 - 모든 클래스는 그 선언과 동시에 Object 클래스를 상속받게 된다. ( 자동으로 ) Sample public class _String { public static void main(String[] args) { String str1="aa"; S..