4 练习: 使用eclipse开发

1       练习: 使用eclipse开发

1.1  练习目标

本例讲述在使用eclipse如何创建groovy程序。

1.2  创建new Groovy project

本例假设你已经安装好了groovy和eclipse并且配置好了。

创建一个新的Groovy的项目

叫做com.vogella.groovy.first

操作如下:the File → New → Other → Groovy → Groovy Project.

 

 

 

最后,创建了一个类似java项目的但是比java项目多了groovy libraries。

 

 

 

 

 

 

Create the following code.

package first

 

class FirstGroovy {

 

    static main(def args) {

       def myList = [1,2,"Lars","4"]

       myList.each {println it}

      

    }

 

}

 

1.3  运行Groovy class

右键,选择“Run As → Groovy Scrip

posted @ 2016-07-26 21:08  遥远2  阅读(161)  评论(0编辑  收藏  举报