내맘대로 Head First Java 정리 8 (static, wrapper, final, format, import static)
The Math method is almost the entire method => In Java, there is no such thing as a battlefield, so it can be called a “most” battlefield method.=>These methods do not depend on the value of the instance variable =>In other words, they do not use any instance variables.=>No instance variables are used at all, so behavior does not change from object to object.=>If you use the keyword static for these methods, you can run them without an instance of the class.=>In other words, the static method means, “The behavior does not change depending on the instance variable, so you don’t need an instance or object, you can only have a class.” =>Ex)Math uses the class name when calling the static method.min(88,86);=> ex)Songt2 with reference variable name when calling generic methods = new Song(); t2.play(); If you specify a method as private, the method can only be invoked in code that is in the same class.=>In other words, if you specify the generator as private, no one outside the class can “new” and create the object.=>Math class also uses this method. You can mix static and non-static methods into one class.=>However, if there is at least one method that is not static, there must be a way to create an instance of that class=>There are three methods to find new objects: using new, using deserialization, and Java Replication API.The static method cannot write a variable (instance variable) that is not a static variable.=>Static methods are called for classes that are not references, so static methods cannot reference any instance variables in that class=>There is no way to know which instance to use in static methods. Static methods cannot use any other method.=>Non-static methods behave differently depending on the normal instance variable (state)=>In other words, if a general method is included in the static method, the instance variable used by the general method cannot be seen and cannot be used.=>Methods that do not use instance variables cannot be used because the possibility of using instance variables remains. Static variables are the same value for any instance in the class=>Static variables are shared by all instances in the class=>That is, there is one for each class, not one for each instance.
The Math method is almost the entire method => In Java, there is no such thing as a battlefield, so it can be called a “most” battlefield method.=>These methods do not depend on the value of the instance variable =>In other words, they do not use any instance variables.=>No instance variables are used at all, so behavior does not change from object to object.=>If you use the keyword static for these methods, you can run them without an instance of the class.=>In other words, the static method means, “The behavior does not change depending on the instance variable, so you don’t need an instance or object, you can only have a class.” =>Ex)Math uses the class name when calling the static method.min(88,86);=> ex)Songt2 with reference variable name when calling generic methods = new Song(); t2.play(); If you specify a method as private, the method can only be invoked in code that is in the same class.=>In other words, if you specify the generator as private, no one outside the class can “new” and create the object.=>Math class also uses this method. You can mix static and non-static methods into one class.=>However, if there is at least one method that is not static, there must be a way to create an instance of that class=>There are three methods to find new objects: using new, using deserialization, and Java Replication API.The static method cannot write a variable (instance variable) that is not a static variable.=>Static methods are called for classes that are not references, so static methods cannot reference any instance variables in that class=>There is no way to know which instance to use in static methods. Static methods cannot use any other method.=>Non-static methods behave differently depending on the normal instance variable (state)=>In other words, if a general method is included in the static method, the instance variable used by the general method cannot be seen and cannot be used.=>Methods that do not use instance variables cannot be used because the possibility of using instance variables remains. Static variables are the same value for any instance in the class=>Static variables are shared by all instances in the class=>That is, there is one for each class, not one for each instance.
=>In instance variable=>In instance variable=>In the instance variable=>In the instance variableクラス class, and two rules.=>1. Static variable is initialized before the object is generated before the object is generated before the class is generated before the first time of the class is generated.=>2. Static variable is initialized before the static method is executed before the static method belongs to the class.variable that is declared in staticinflation =>findependent, the variable that value is not changed.=> means that the variable that the default value is the only =>Statically specifies the same value for the default value for the specified by default =>Static filter = The method to initialize the constant, which is not the static filter that is the static fAR_SIGN) that is not a static fAR_SIGN) that is the static {status}.The default is not available for static variables to specify the default =>The class to specify the class => to specify the class => to specify the class => method for example, which is notification.If you specify the class is already specified, the method is not allowed to specify the default =>You can’t override any longer exceed the extension.=> However, one method is to override the method when you can’t be overwritten and can’t be able to override the method.Path method =>Method value less than 1.0 or more than 1.0.0 or more than 1.0.0 or more1.0 or less than 1The value that represents the absolute value of the given factor is given to the maximum number of factors specified factors, and long as the return=>Path = The two factors are lower than the return=>Path.max() =>Path.max()二Some of two factors, the rapper (wrapper) is also used to handle all primitive types of factors.=>>>You can easily understand all primitive types, but the first character is a master of the first character = Chars=>Channel with the first character = Inspiron= Integrator
When packing the value is packing with the printer, the Intel= newIntegrammable = newIntegrammableWhen you remove packaging using iWrap.intValue() and object reference is not used to replace the original variable and object reference to the object reference is strictly classified.=> However, the translation between primitive values and the rapper object.=>When you add to ArrayList, only when you add a number 3 to the ArrayList.=>A automatically boxing is always available to the type of raptions that type, and the primitive value is to be used.=>If you enter values, you can use Intel Inside the value.Some of the rapper has a few useful static methods.=>The representative method, but returns the String and returns the desired primitive type of primitive type of primitive typeString = Integration= Integration ” Integration, two ways to convert primitive numbers to Sting.parameters.=>//#1 + operator using the 1. + operator 42.5; String double String = “+d) Router = = =>exe d) Router accounting method 42.5; String double String = Double.to String(d);Formatting=>Fomatting=>Fomats to change the format, which means to change the format.When you can notation, the number of people who use the configuration =>String formatting the number of factors that are entered in the table, and the number of factors that are displayed in the first time.accuracy] be divided into the type=>type is required, but the remaining parentheses are selected from the remaining parentheses=>If you look at the type, %d=A decimal integer, %f= hexadecimal, %x= hexadecimal, %c= hexadecimal, the number of the number of the generation of the generation.How to Formatting Date =>%tc = When you display date and time, the %tA, the %tA, the maximum of %tA, the maximum of %tA, the day of the day.=> Basic concept is to use static importance, static variables, static importance, and deny only the method of using static importance
Import the package org.example;static Java.time.LocalDateTime.now;public クラス Main {public static void main(String[] args) { Calcal(); System.out.println((int) (Math.random() * 5)); // 전역 메서드 이기 때문에 class 명을 가지고 메서드 호출 cal.add(10, 5); // 일반 메서드를 호출할때는 레퍼런스 변수명으로 호출 Date.now(); // static 메서드라서 클래스명으로 호출가능 Date time= newTime(); //다형성 time。minute (); // 오버라이드된 일반메서드 호출 int i = 288; Integer iWrap = new Integer(i); // Integer 로 포장하는 옛날 방식 int unWraped= iWrap.intValue(); // 포장을 벗겨내는 옛날방식 intunWraped2= i; // iWrap; // String을 원시변수로 변환 (파싱이라함) String = “2”; int x= Integer.parseInt(s);// 원시변수를 String 으로 변환 (파싱) doubled = 42.5; String doubleString = ” ” + d; String doubleString2 = double.toString(d);// 숫자 포매팅 System.out.println(String)(String).format(“%d”, 1000000); // 옛날 방식 System.out.printf(“%d%n”, 1000000); // 요즘 사용 방식// 날짜 포매팅 System.out.println(String.format (“%tr”, now ())); // 옛날 방식 // 정적임포트를 사용해 now ()를 바로 사용 System.out.printf(“%tr%n”, now ()); // 요즘 사용 식} final class Cal { // 확장 불가능 public static final int NUM= 10; // / / 상수라서 변경 불가 public voidadd(int n1, int n2){ System.out.println(n1 + n2);}class {public static int time;int minute;public static void now () { // 오버라이드 불가 time = 10;System.out.println(“now:” + time);// minute // 일반 변수 사용 불가 public void minute () { //오버라이드 가능}class 時間拡張日付{public void minute minute= 30; System.out。println(“minute : ” + minute);}}