Сообщения

Сообщения за ноябрь, 2022

Logback

 logback.xml <configuration> <appender name ="STDOUT" class ="ch.qos.logback.core.ConsoleAppender" > <encoder> <pattern> %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n </pattern> </encoder> </appender> <root level ="info" > <appender-ref ref ="STDOUT" /> </root> </configuration> <configuration> <appender name ="CONSOLE" class ="ch.qos.logback.core.ConsoleAppender" > <encoder> <Pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%15.15t] %40.40c{40} - %msg%n </Pattern> </encoder> </appender> <root level ="INFO" > <appender-ref ref ="CONSOLE" /> </root> </configuration>

Linux

 1. netstat -ant | findstr "8080" : to find whether the port is busy 2. netstat -anto | findstr "8080" : to find whether the port is busy

Real HashCode of an Object

  https://www.geeksforgeeks.org/system-identityhashcode-method-in-java-with-examples/ Scanner in = new Scanner( System . in ) ; String one = "something" ; String two = "something" ; String three = new String( "something" ) ; String four = in .nextLine() ; System . out .println( one .hashCode()) ; System . out .println( two .hashCode()) ; System . out .println( three .hashCode()) ; System . out .println( one == two ) ; // true System . out .println( one == three ) ; // false System . out .println( one == three .intern()) ; // true System . out .println( one == four ) ; // false System . out .println( one == four .intern()) ; // true int oneHash = System . identityHashCode ( one ) ; int twoHash = System . identityHashCode ( two ) ; int threeHash = System . identityHashCode ( three ) ; int fourHash = System . identityHashCode ( four ) ; System . out .println( oneHash ) ; System . out .println( twoHash ) ; System . out .println( threeHash ) ; System . out .pri

Project "social"

 1. yaml file: allow-bean-definition-overriding ->  https://www.baeldung.com/spring-boot-bean-definition-override-exception 2. yaml file: spring: jpa: open-in-view ->  https://stackoverflow.com/questions/30549489/what-is-this-spring-jpa-open-in-view-true-property-in-spring-boot 3. @Data : could cause some problems:  https://stackoverflow.com/questions/38572566/warning-equals-hashcode-on-data-annotation-lombok-with-inheritance 4. Hibernate GenerationType.Identity vs GenerationType.Sequence https://stackoverflow.com/questions/66461658/hibernate-generationtype-identity-vs-generationtype-sequence

Lesson: Java Collection Api

Изображение
Problems with simple arrays: package org.example ; public class Main { public static void main ( String [] args ) { String [] students = { "One" , "Two" , "Three" , "Four" } ; for ( String s : students ) { System . out .println( s ) ; } // yenisi elave olundu String [] second = new String[ students . length + 1 ] ; for ( int i = 0 ; i < students . length ; i ++) { second [ i ] = students [ i ] ; } second [ second . length - 1 ] = "Five" ; students = second ; for ( String s : students ) { System . out .println( s ) ; } // biri cixdi students [ 2 ] = null ; String [] third = new String[ students . length - 1 ] ; for ( int i = 0 , j = 0 ; i < students . length ; i ++) { if ( students [ i ] != null ) { third [ j ] = students [ i ] ; j

Oracle - Generics

1. Generic types 1.1 A simple Box Class package org.oracle ; public class Box { private Object object ; public void set ( Object object ) { this . object = object ; } public Object get () { return object ; } }   package org.oracle ; public class Main { public static void main ( String [] args ) { Box box = new Box() ; box .set( 5 ) ; String name = ( String ) box .get() ; } } 1.2 A Generic version of the Box Class package org.oracle ; public class Box < T > { private T t ; public void set ( T t ) { this . t = t ; } public T get () { return t ; } } package org.oracle ; public class Main { public static void main ( String [] args ) { Box < String > box = new Box<>() ; box .set( "abc" ) ; String s = box .get() ; } } 1.3 Multiple type parameters package org.oracle ; public interface Pair < K , V > { public K getKey () ;