本地代码也可以与字节码区分开来

本地代码也可以与字节码区分开来(有时候叫做编译代码),这种代码可以在 虚拟机上运行(比如JAVA虚拟机)。

虚拟机是一个把通用字节码转换成用于特定处理器的本地代码的程序。微软的.NET 编译器产生的就是字节码(微软叫它作 中间语言)。

Java字节码和微软的中间语言都能在执行前被即时编译器编译成高性能的本机代码。

 

 1 package Com.TableTest;
 2 
 3 class Movie{
 4     //实例对象
 5     String title;
 6     String genre;
 7     int rating;
 8     //方法
 9     void playIt(){
10         System.out.println("Playing the movie"); 
11         System.out.println(this.title);
12         System.out.println(this.genre);
13         System.out.println(this.rating);
14     }
15 }
16 
17 public class TableText_13 {
18     //编写测试用的类
19        public static void main(String[] args){
20       //建立movie对象
21       Movie one = new Movie();
22       //圆点运算符引用
23       one.title = "Gone with the Stock";
24       one.genre = "Tragic";
25       one.rating = -2;
26       one.playIt();
27       
28       //建立movie对象
29       Movie two = new Movie();
30       two.title = "Lost in Cubicle Space";
31       two.genre = "Comedy";
32       two.rating = 5;
33      //调用方法
34       two.playIt();
35       
36        }
37 }

 

posted @ 2018-07-30 01:51  borter  阅读(443)  评论(0编辑  收藏  举报