Сообщения

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

Data Types, Variables and Arrays

 Java defines 8 primitive(simle) types of data: byte, short, int, long, char, float, double, boolean.  Byte  - the smallest integer type. This is a signed 8-bit type that has a range from -128 to 127. Short - is a signed 16-bit type. It has range from -32,768 to 32767. Int - is a signed 32-bit type that has a range from -2,147,483,648 to 2,147,483,647.  Long - is a signed 64-bit type. Float  - specifies single-precision value that uses 32 bits of storage. Double - uses 64 bits of storage. Char - is 16-bit type. The range of a char 0 to 65,536. There are no negative chars. Boolean - has two possible values true or false. Integer Literals. An integer literal can always be assigned to a long variable. You do this by appending an upper- or lowercase L to the literal. For example, 0x7fffffffL or 12345L.  You can also specify integer literals using binary. To do so, prefix the value with 0b or 0B .  int x = 0b1010; Octal values are denoted in Java by leading zero.Normal decimal numbers canno

Arrays.asList

package az.parvin ; import java.util.Arrays ; import java.util.List ; public class Main { public static void main ( String [] args ) { String [] names = new String[] { "Mike" , "Cyril" , "Tom" } ; Integer [] numbers = new Integer[] { 1 , 2 , 3 } ; List < Integer > list1 = Arrays . asList ( 1 , 2 , 3 ) ; List < String > list2 = Arrays . asList ( "Parvin" , "Narmin" , "Parvana" ) ; List < String > list3 = Arrays . asList ( names ) ; List < Integer > list4 = Arrays . asList ( numbers ) ; System . out .println( list1 ) ; System . out .println( list2 ) ; System . out .println( list3 ) ; System . out .println( list4 ) ; } } "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=3187:C:\Program Files\JetBrains\IntelliJ IDEA 2020

Http Session

  package com.example.demo ; public class Cart { private String name ; private int quantity ; public String getName () { return name ; } public void setName ( String name ) { this . name = name ; } public int getQuantity () { return quantity ; } public void setQuantity ( int quantity ) { this . quantity = quantity ; } } package com.example.demo ; import javax.servlet.ServletException ; import javax.servlet.annotation. WebServlet ; import javax.servlet.http.HttpServlet ; import javax.servlet.http.HttpServletRequest ; import javax.servlet.http.HttpServletResponse ; import javax.servlet.http.HttpSession ; import java.io.IOException ; import java.io.PrintWriter ; @WebServlet (name = "FirstServlet" , urlPatterns = "/first" ) public class FirstServlet extends HttpServlet { @Override protected void doGet ( HttpServletRequest req , HttpServletResponse resp ) throws ServletException , IOException

Tomcat, Web Server

Изображение
 Web Server - is a computer program, for accepting, processing and returning(replying) HTTP responses. For example Web Server accepts request then transmits it to some server programming  language (PHP, Java, C#...) .  Tomcat is Web Server which contains Servlets. Tomcat runs interminably and accepts requests from client, redirect to servlets and responds to clients.

Marshaller and Unmarshaller (JAXB - Java Architechture for XML Binding)

 Marshaller allows us to write an object to a xml file.  https://www.youtube.com/watch?v=ZtQ5-c4nAKY package main ; import javax.xml.bind.annotation. XmlElement ; import javax.xml.bind.annotation. XmlRootElement ; @XmlRootElement public class Employee { private String name ; private int number ; private int age ; private String mail ; private String city ; @XmlElement public void setName ( String name ) { this . name = name ; } @XmlElement public void setNumber ( int number ) { this . number = number ; } @XmlElement public void setAge ( int age ) { this . age = age ; } @XmlElement public void setMail ( String mail ) { this . mail = mail ; } @XmlElement public void setCity ( String city ) { this . city = city ; } public String getName () { return name ; } public int getNumber () { return number ; } public int getAge () { retu

CSS - Cascading Style Sheets

 1. h3 {      color :  green ;      font-size :  20 ; } <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < title > Css ders 1 </ title > </ head > < body >      < link   rel = "stylesheet"   type = "text/css"   href = "style.css" >      < style >          h2 {              color :  blue ;         }      </ style >      < h1   style = " color: red; " > This is CSS lessons </ h1 >      < h2 > This is Css lesson </ h2 >      < h3 > This is Css lesson </ h3 > </ body > </ html >

HTML - Hypertext Markup Language

1. Tag <a></a> - defines a hyperlink. <! DOCTYPE   html > < html   lang = "en" > < head >      < meta   charset = "UTF-8" >      < meta   http-equiv = "X-UA-Compatible"   content = "IE=edge" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < title > Pi Academy </ title > </ head > < body >      <!--         rel - Hazirki sehife ile baglanti verilmiw sehife arasinda elaqeni gosterir         noopener noreferrer - tehlukesizlik ucundur         nofollow - mesuliyyeti boynundan atir         stylesheet - acilan sehifede stil wablonlari oldugunu bildirir         alternate - yeni acilacaq sehife hazirki sehifenin bir alternatividir         target - baglantinin harada acilacagini gosterir         _blank - baglantini yeni pencerede acir         _self - baglantini hemin sehifede acir         _parent - baglantini esas pen

Generics from book(Herbert Schild)

  A Simple Generics Example. package main ; public class Gen < T > { T ob ; public Gen ( T o ) { ob = o ; } public T getob () { return ob ; } public void showType () { System . out .println( "Type of T is : " + ob .getClass().getName()) ; } } package main ; public class Main { public static void main ( String [] args ) { Gen < Integer > iOb = new Gen<>( 29 ) ; iOb .showType() ; System . out .println( iOb .getob()) ; Gen < String > strOb = new Gen<>( "Salam" ) ; strOb .showType() ; System . out .println( strOb .getob()) ; } } Output: Type of T is : java.lang.Integer 29 Type of T is : java.lang.String Salam

Variables

  Local variable. Variables declared inside a scope are not visible (that is, accessible) to code that is defined outside that scope. Thus, when you declare a variable within a scope, you are localizing that variable and protecting it from unauthorized access and/or modification. A variable declared within a block is called a local variable. Objects declared in the outer scope will be visible to code within the inner scope. However, the reverse is not true.

Exception

An exception is a run-time error. Any code that absolutely must be executed after a try block completes is put in finally block.  package main ; public class Main { public static void main ( String [] args ) { int d , a ; try { // monitor a block of code d = 0 ; a = 42 / d ; System . out .println( "This will not be printed." ) ; } catch ( ArithmeticException e ) { // catch divide-by-zero error System . out .println( "Division by zero." ) ; } System . out .println( "After catch statement." ) ; } } Output: Division by zero. After catch statement. println() inside the try block is never executed. Once an exception is thrown, program control transfers out of the try block into the catch block.

Interfaces

 Variables in Interfaces are by default public static final, meaning they cannot be changed by the implementing class . Methods in Interfaces are by default public abstract.  Default Methods in Intefaces. The dafault method declaration is preceded by the keyword default modifier .   package main.p3 ; public interface SharedConstrant { default void foo () { System . out .println( "foo" ) ; } } It is also possible to intialize static method in Interface. package main.p4 ; public interface A { default void foo () { System . out .println( "foo in A" ) ; } static int getInt () { return 1 ; } } int number = A.getInt(); Remember! static interface methods are not inherited by either an implementing class or a subinterface. Beginning with JDK 9, an interface can include a private method. A private interface method can be called only by a default method or another private method defined by the same interface. Because a private i

Packages

Изображение
  Class member access