Сообщения

Сообщения за июль, 2021

What is the difference between Integer.valueOf() and Integer.parseInt() ?

 1. Integer.valueOf() returns an Integer object while Integer.parseInt() returns a primitive type. // Program to show the use // of Integer.parseInt() method class Test1 { public static void main(String args[]) { String s = "77"; // Primitive int is returned int str = Integer.parseInt(s); System.out.print(str); // Integer object is returned int str1 = Integer.valueOf(s); System.out.print(str1); } } Output: 7777

Timestamp

  Метод valueOf() класса java.sql.Timestamp принимает значение String, представляющее метку времени в escape-формате JDBC, и преобразует данное значение String в объект Timestamp. Timestamp.from - accepts Instant. Timestamp.valueOf - accepts either String or LocalDateTime.

Architechture 4

Изображение
 

MD5

package main ; import javax.xml.bind.DatatypeConverter ; import java.security.MessageDigest ; import java.security.NoSuchAlgorithmException ; public class Main { public static void main ( String [] args ) { String name = "ghost" ; try { byte [] digest = MessageDigest . getInstance ( "MD5" ).digest( name .getBytes()) ; String hash = DatatypeConverter . printHexBinary ( digest ).toUpperCase() ; System . out .println( hash ) ; } catch ( NoSuchAlgorithmException e ) { e .printStackTrace() ; } } }  

Enumeration

package main ; public enum Apple { Jonathan , GoldenDel , RedDel , Winesap , Cortland } package main ; public class Main { public static void main ( String [] args ) { Apple ap = Apple . RedDel ; System . out .println( "Value of ap: " + ap ) ; ap = Apple . GoldenDel ; if ( ap == Apple . GoldenDel ) System . out .println( "ap contains GoldenDel" ) ; switch ( ap ){ case Jonathan : System . out .println( "Jonathan is red." ) ; break ; case GoldenDel : System . out .println( "Goldel Delicious is yellow" ) ; break ; case Winesap : System . out .println( "Winesap is red" ) ; break ; } } } Output is: "C:\Program Files\Java\jdk1.8.0_281\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.3.2\lib\idea_rt.jar=74

Servlet

 The browser is the piece of software (like Netscape or Mozilla) that knows how to communicate with the server. Client is the browser app doing what the user asked it to do. HTML tells the browser how to display content to the user.  HTTP is the protocol clients and servers use on the web to communicate. The server use HTTP to send HTML to the client. TCP is responsible for making sure that a file sent from one network node to another ends up as a complete file at the destination, even though the file is split into chunks when it's sent. IP is the underlying protocol that moves/routes the chunks (packets) from one host to another on their way to the destionation. HTTP , then is another network protocol that has Web-specific features, but it depends on TCP/IP to get the complete request and response from one place to another. The stucture of an HTTP conversation is a simple Request/Response sequence. 

Escape character

 \ backslash is an escape character in Java.  Escape Sequences Escape Sequence Description \t Insert a tab in the text at this point. \b Insert a backspace in the text at this point. \n Insert a newline in the text at this point. \r Insert a carriage return in the text at this point. \f Insert a form feed in the text at this point. \' Insert a single quote character in the text at this point. \" Insert a double quote character in the text at this point. \\ Insert a backslash character in the text at this point. System.out.println("She said \"Hello!\" to me."); She said "Hello!" to me.