'Back-End/Java_1'에 해당되는 글 48건

donaricano-btn

UnicodeSystem

- Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages


1. Why java uses Unicode System

There were many language standards

- ASCII : for the United States

- ISO 8859-1 : for Western European Language

- KOI-8 : for Russian

- GB18030 and BIG-5 : for chinese and so on


2. Problem

- A particular code value corresponds to different letters in the various language standards

- The encodings for languages with large character sets have variable length, Some common characters are encoded as single bytes, other require two or more byte


3. To solve the problem

A new language standard was developed i.e. Unicode System

In unicode, character holds 2 byte, so java also uses 2byte for charaters


4. etc

- lowest value : \u0000

- highest value : \uFFFF

'Back-End > Java_1' 카테고리의 다른 글

[Java] Java OOPs Concepts  (0) 2016.06.27
[Java] Json  (0) 2016.06.15
[Java] JVM  (0) 2016.06.03
[Java] JDK, JRE, and JVM  (0) 2016.06.03
[Java] Exception  (0) 2016.05.18
블로그 이미지

리딩리드

,

[Java] JVM

Back-End/Java_1 2016. 6. 3. 18:05
donaricano-btn

JVM

- It is a specification where working of Java Virtual Machine is specified

- An implementation Its implementation is known as JRE

- Runtime Instance whenever you write java command on the command prompt to run the java class, and instance of JVM is created


1. What it does?

1_1 The JVM performs following operation

- Loads code

- Verifies code

- Executes code

- provides runtime environment


1_2. JVM provides definitions for the

- Memory area

- Class file format

- Register set

- Garbage-collected heap

- Fatal error reporting etc


2. Internal Architecture of JVM


1) Classloader

- Classloader is a subsystem of JVM that is used to load class file

2) Class(Method) Area

- Class(Method) Area stores per-class structures such as the runtime constant pool, field and method data, the code for method

3) Heap

- It is the runtime data area in which objects are allocated

4) Stack

- Java stack stores frames. It holds local variables and partial results, and plays a part in method invocation and return 

- Each thread has a private JVM stack, created at the same time as thread

- A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes

5) Program Counter Register

- PC(program counter) register. It contains the address of the Java virtual machine instruction currently being executed

6) Native Method Stack

- It contains all the native methods used in the application 

7) Execution Engine

- It contains

: A virtual processor

: Interpreter, Read bytecode stream then execute the instructions

: Just-In-Time(JIT) compiler 

It is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of the time needed for compilation.


'Back-End > Java_1' 카테고리의 다른 글

[Java] Json  (0) 2016.06.15
[Java] UnicodeSystem  (0) 2016.06.10
[Java] JDK, JRE, and JVM  (0) 2016.06.03
[Java] Exception  (0) 2016.05.18
[Java] Constructor  (0) 2016.05.17
블로그 이미지

리딩리드

,
donaricano-btn

JDK, JRE, and JVM


1. JVM

- JVM is an abstraction machine. It is a specification that provides runtime environment in whick java bytecode can be executed

- JVMs are avaliable for many hardware and software platform. 

- JVM, JRE, and JDK  are platform dependent because configuration of each OS differs

- Java is platform independent


1_1. JVM performs following main task

- Loads code

- Verifes code

- Executes code

- Provides runtime enviroment


2. JRE

- JRE is an acronym for Java Runtime Enviroment

- It is used to provide runtime enviroment. 

- It is the implementation of JVM. It physically exists

- It contains set of libraries + other files that JVM uses at runtime


3. JDK

- JDK is an acronym for Java Development Kit

- It contains JRE + development tools


4. At compile time

- At compile time, java file is compiled by java Compiler and convert the java code into bytecode


4_1. At runtime

- classloader : is the subsystem of JVM that is used to load class files

- Bytecode Verifier : checks the code fragments for illegal code that can violate access right to objects

Interpreter : read bytecode stream then execute the instructions

'Back-End > Java_1' 카테고리의 다른 글

[Java] UnicodeSystem  (0) 2016.06.10
[Java] JVM  (0) 2016.06.03
[Java] Exception  (0) 2016.05.18
[Java] Constructor  (0) 2016.05.17
[Java] Enum  (0) 2016.05.13
블로그 이미지

리딩리드

,

[Java] Exception

Back-End/Java_1 2016. 5. 18. 15:30
donaricano-btn

Exception

- An exception is an event, which occurs during the execution of a program, that interrupts the normal flow of the program

- The Throwable class is the superclass of all errors and exceptions in the java language

- Exceptions can be handled by using 'try-catch' block

- If a method doesn't handle the exception, then it is mandatory to specify the exception type in the method signature using 'throws' clause

- We can explicitly throw an exception using 'throw' clause


1. How Exception terminates java program

whenever exception arises, it terminates the program execution, means it stops the execution of the current java program


2. Handling

Exceptions can be handled by using "try-catch" block


3. Throws

The throws clause in java programming language is belongs to a method to specify that the method raises particular type of exception while being executed

Anybody calling a method with a throws clause is needed to be enclosed within the try catch blocks


4. Throw

Use 'throw' statement to throw an exception or simply use the throw clause with an object reference to throw an excpetion

The syntax is 'throw new Exception();' Even you can pass the error message to the Exception constructor


5. Multiple Catch Blocks

A single try blocks can have multiple catch blocks. This is required when the try block has statements that generates different types of exceptions

If the first catch block contains the Exception class object then subsequent catch blocks are never executed

The last catch block in multiple catch blocks must contain the Exception class object.

This is because, the java compiler gives an error saying that the subsequent catch blocks haven't been reached. This is known as Unreachable code problem


6. Finally

- The finally block always executes immediately after try-catch block exits

The finally block is executed incase even if an unexpected exception occurs

The main usage of finally block is to do clean up job

The runtime system always executes the code within the finally block regardless of what happens in the try block, so it is the ideal place to keep cleanup code


7. Without Catch

- You can handle exception still without having catch blocks also, only thing you need to do is declare the throws clause in your method signature, so that the calling function would handle the exception, Before throwing exception, it executes the finally block


8. Custom Exception

Sometimes it is required to develop meaningful exceptions based on application requirements. We can create our own exceptions by extending 'Exception' class



'Back-End > Java_1' 카테고리의 다른 글

[Java] JVM  (0) 2016.06.03
[Java] JDK, JRE, and JVM  (0) 2016.06.03
[Java] Constructor  (0) 2016.05.17
[Java] Enum  (0) 2016.05.13
[Java] Array  (0) 2016.05.12
블로그 이미지

리딩리드

,