Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Java

Verification ใน Java (JVM) คืออะไร

เมื่อโหลด Bytecode โดย JVM (ด้วยไฟล์ .class) Bytecode จะถูกตรวจสอบความถูกต้องโดย Verifier Verifier ตรวจสอบการเชื่อมโยง (linking) เพื่อให้การดำเนินการมีประสิทธิภาพ ทำให้ Interpreter ทำงานได้มีประสิทธิภาพมากขึ้น กระบวนการนี้เรียกว่า Verification

ตัวอย่าง

public class Demo{ 
    private float my_val; 
    float my_function(int my_val){ 
        int balance = my_val; 
        this.my_val += balance; 
        return this.my_val; 
    } 
    public static void main(String[] args){ 
        Demo my_obj = new Demo(); 
        System.out.println("The instance of Demo has been created"); 
        System.out.println(my_obj.my_function(3456)); 
    } 
}

ผลลัพธ์

The instance of Demo has been created 3456.0

คลาส Demo มีค่า float ฟังก์ชัน my_function บวกค่าที่ให้มากับค่า float ใน main สร้างอินสแตนซ์ของ Demo และเรียก my_function แสดงผลบนคอนโซล