Lesson1: JDK, JVM, JRE

1. Compiler - takes the entire programming code written in high
language and translates the whole of it into machine code at once. 
After this process the an executable file will be ready to run. 


The translation takes some times to be done, but after that execution
is so fast.

2. Interpreter - takes each single instructions of the code
translates it and then executes it on its own. The translation step 
is before the program runs is fast, but execution is slow.

JDK = JRE + development tools
JRE = JVM + library class
JDK -> Java Development Kit. A kit which provides the environment to 
develop and execute (run) Java program. 
JRE -> Java Runtime Environment. Provides environment to only run. 
JVM -> Java Virtual Machine














f
* Compiled: Fortran, C, C++, Pascal, Haskell, Rust, Go
* Interpreted: JavaScript, PHP, Python, Ruby


Java both compiled and interpreted language.




Terminalda : javac Main.java yazdiqda, source fayli(.java) bytecode(.class) faylina cevirir.

Terminalda: java Main (bu zaman biz interpreter-i) ishe saliriq.

Indi ise bytecode baxaq. Terminalda: javap -c Main.class


Yeni javac.exe compiler-i ishe salir; java.exe java virtual machine ishe salir.

------------------------------------------------------------------------------------------------------------------------------

                                                                Compile time vs Run time

package az.etibarli;

public class Main {
public static void main(String[] args) {
int a = 2_147_483_647;
int b = a + 1;
System.out.println(b);

// Unreachable code
int c = 5;
int d;
if (c < 20)
d = 100;
System.out.println(d);
}
}


-- Block

{}

-- Bir source kodda 1 den cox public class ola bilmez. 

------------------------------------------------------------------------------------------------------------------------------

                                                                    Data types

Primitiv tipler arifmetik, character ve mentiqi ishleri rahat etmek ucun Javaya daxil edilmishdir.

8 primitiv tip var:

byte, short, int, long, float, double, char, boolean.

Numeric olmayan tip: boolean. Qalanlari ise numeric-dir.


char a = 'a';
System.out.println((int) a);
char b = 97;
System.out.println(b);
char c = (char) -100;
System.out.println(c);

char yaddashda 2 byte yer tutur.

char a = '\u0000';
char b = '\u0001';
char c = '\u0002';
char d = '\uffff';
System.out.printf("%s %s %s %s\n", a, b, c, d);

String helloInJapanese = "\u4eca\u65e5\u306f\u4e16\u754c";
String helloInArabic = "\u0633\u0644\u0627\u0645";
System.out.println(helloInJapanese);
System.out.println(helloInArabic);

InputStreamReader isr = new InputStreamReader(System.in);
System.out.println(isr.getEncoding());
Locale locale = Locale.getDefault();
System.out.println(locale.getCountry());
System.out.println(locale.getDisplayLanguage());


SortedMap charsets = Charset.availableCharsets();
Set names = charsets.keySet();
for (Iterator e = names.iterator(); e.hasNext(); ) {
String name = (String) e.next();
Charset charset = (Charset) charsets.get(name);
System.out.println(charset);
Set aliases = charset.aliases();
for (Iterator ee = aliases.iterator(); ee.hasNext();) {
System.out.println(" " + ee.next());
}
}

-- Escape character

System.out.println("Quotation mark: " + "\"Parvin's\"");


-- Binary representation

int a = 0b101;
int b = 0B101;
System.out.println(a + "\n" + b);

-- Octadecimal representation

int a = 0132;
int b = 01234567;
System.out.println(a + "\n" + b);

-- Hexadecimal representation

int a = 0x123a;
int b = 0Xabcdef;
System.out.println(a + "\n" + b);

-- Problems with float and double

float sumOfSix = 0.1F + 0.1F + 0.1F + 0.1F + 0.1F + 0.1F;
System.out.println(sumOfSix);
float sumOfSeven = sumOfSix + 0.1F;
System.out.println(sumOfSeven);

float sum = 0;
for (int i = 0; i < 100; i++) {
sum += 0.1F;
}
System.out.println(sum);

double sum2 = 0;
for (int i = 0; i < 100; i++) {
sum2 += 0.1D;
}
System.out.println(sum2);


-- Declaration:

int a;

-- Initialization:

int a;
a = 7;

-- Definition: definition = declaration + initialization

int a = 7;



Комментарии

Популярные сообщения из этого блога

SE_21_Lesson_11: Inheritance, Polymorphism

SE_21_Lesson_9: Initialization Blocks, Wrapper types, String class