Giriş
JVM iki tane goto Opcode tanımlıyor. Bunlar
- goto
- goto_w
goto Opcode
Açıklaması şöyle.
Açıklaması şöyle.
JVM iki tane goto Opcode tanımlıyor. Bunlar
- goto
- goto_w
goto Opcode
Açıklaması şöyle.
... goto is a reserved keyword in the Java language but is not actually used. And you probably also know that goto is a Java Virtual Machine (JVM) opcode.goto_w Opcode
Açıklaması şöyle.
Whereas goto takes a 2-byte branch offset, goto_w takes a 4-byte branch offset. The spec states thatBir başka açıklama şöyle.
The size of the method code can be as large as 64K.The branch offset of the short goto is a signed 16-bit integer: from -32768 to 32767.So, the short offset is not enough to make a jump from the beginning of 65K method to the end.
labeled Break
Örnek
Şöyle yaparız
public static void firstNumsToSum(List<Integer> nums1, List<Integer> nums2, int sum) {outer: for (Integer n1 : nums1) {inner: for (Integer n2 : nums2) {if (n1 + n2 == sum) {break outer;}System.out.println("n1=" + n1 + ", n2=" + n2);}System.out.println("here");}
Örnek
Şöyle yaparız
public void updateDBRecord(User userToUpdate) { System.out.println("open DB connection"); tryToPersist: try { User existingUser = db.read(userToUpdate.getUid()); if (!needToUpdateRecord(existingUser, userToUpdate)) { break tryToPersist; } // recalculate + persist System.out.println("persist"); } catch (Exception e) { System.out.println("Catastrophe"); } finally { //close DB connection System.out.println("close DB connection"); } }
Hiç yorum yok:
Yorum Gönder