SlideShare a Scribd company logo
Groovy




                Java

2011   5   28
Java
                            2011 05/28
                Slide # 2
2011   5   28
Java
                            2011 05/28
                Slide # 3
2011   5   28
$ cat input.txt
                      That that is is that that is
                      not is not is that it it is

                      $ java WordCount input.txt
                      1: [That]
                      2: [not]
                      2: [it]
                      4: [that]
                      6: [is]                                     Java
                                                     2011 05/28
                Slide # 4
2011   5   28
Java                WordCount:48        Set<Map.Entry<String, Integer>> entrySet =
 import         java.util.Comparator;              map.entrySet();
 import         java.util.HashMap;                      Object[] list = entrySet.toArray();
 import         java.util.Map;                           Comparator comp = new Comparator(){
 import         java.util.Set;                            public int compare(Object o1, Object o2)
 import         java.util.List;                    {
 import         java.util.Arrays;                           Map.Entry<String, Integer> e1 =
 import         java.io.FileReader;                (Map.Entry<String, Integer>) o1;
 import         java.io.BufferedReader;                     Map.Entry<String, Integer> e2 =
 import         java.io.FileNotFoundException;     (Map.Entry<String, Integer>) o2;
 import         java.io.IOException;                         return e1.getValue() - e2.getValue();
                                                           }
 public class WordCount {                                };
   @SuppressWarnings(value = "unchecked")                Arrays.sort(list, comp);
   public static void main(String[] args) {              for (Object it: list) {
     FileReader fis = null;                                Map.Entry<String, Integer> entry =
     BufferedReader br = null;                     (Map.Entry<String, Integer>)it;
     try {                                                 System.out.println(entry.getValue() + ":
       HashMap<String, Integer> map = new          ["+entry.getKey()+"]");
 HashMap<String, Integer>();                             }
       fis = new FileReader(args[0]);                  }
       br = new BufferedReader(fis);                   catch (IOException e) {
       String line;                                      try {if (br != null) br.close();}catch
       while ((line = br.readLine()) != null) {    (IOException ioe){}
         for (String it: line.split("s+")) {           try {if (fis != null)fis.close();}catch
           map.put(it, (map.get(it)==null) ? 1 :   (IOException ioe){}
 (map.get(it) + 1));                                     e.printStackTrace();
         }                                             }

                                                                                            Java
       }                                             }
                                                   }
                                                                    2011 05/28
                Slide # 5
2011   5   28
Groovy         WordCount(9                )
           def map = [:].withDefault{0}
           new File(args[0]).eachLine {
             it.split(/s+/).each {
               map[it]++
          }
           }
           map.entrySet().sort{it.value}.each {
             println "${it.value}: [${it.key}]"
           }




                                                               Java
                                                  2011 05/28
                Slide # 6
2011   5   28
Java
                                                               Set<Map.Entry<String, Integer>>
 import         java.util.Comparator;              entrySet = map.entrySet();
 import         java.util.HashMap;                             Object[] list = entrySet.toArray();
 import         java.util.Map;                                 Comparator comp = new Comparator(){
 import         java.util.Set;                                     public int compare(Object o1,
 import         java.util.List;                    Object o2) {
 import         java.util.Arrays;                                      Map.Entry<String, Integer> e1
 import         java.io.FileReader;                = (Map.Entry<String, Integer>) o1;
 import         java.io.BufferedReader;                                Map.Entry<String, Integer> e2
 import         java.io.FileNotFoundException;     = (Map.Entry<String, Integer>) o2;
 import         java.io.IOException;                                   return e1.getValue() -
                                                   e2.getValue();
 public class WordCount {                                          }
     @SuppressWarnings(value = "unchecked")                    };
     public static void main(String[] args) {                  Arrays.sort(list, comp);
         FileReader fis = null;                                for (Object it: list) {
         BufferedReader br = null;                                 Map.Entry<String, Integer> entry
         try {                                     = (Map.Entry<String, Integer>)it;
             HashMap<String, Integer> map = new                    System.out.println(entry.getValue
 HashMap<String, Integer>();                       () + ": ["+entry.getKey()+"]");
             fis = new FileReader(args[0]);                    }
             br = new BufferedReader(fis);                 }
             String line;                                  catch (IOException e) {
             while ((line = br.readLine()) !=                  try {if (br != null) br.close();}
 null) {                                           catch(IOException ioe){}
                 for (String it: line.split("s               try {if (fis != null)fis.close();}
 +")) {                                            catch(IOException ioe){}
                     map.put(it, (map.get(it)                  e.printStackTrace();
 ==null) ? 1 : (map.get(it) + 1));
                 }
                                                           }
                                                       }
                                                                                           Java
             }                                     }                2011 05/28
                Slide # 7
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 8
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 9
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 10
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 11
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 12
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 13
2011   5   28
Groovy         WordCount(9                           )
           def map = [:].withDefault{0} // value                    0         map
           new File(args[0]).eachLine { //
             it.split(/s+/).each {     //          /s+/
               map[it]++                //     map                        1
             }
           }
           map.entrySet().sort{it.value}.each {// map       entrySet      value
             println "${it.value}: [${it.key}]"//               key,value
           }




                                                                                  Java
                                                             2011 05/28
                Slide # 14
2011   5   28
Java
                             2011 05/28
                Slide # 15
2011   5   28
public final class Person {                                       if (obj == null)
           private final String firstName;                                   return false;
           private final String lastName;                                if (getClass() != obj.getClass())
                                                                             return false;
            public Person(String firstName, String lastName) {           Person other = (Person) obj;
                this.firstName = firstName;                              if (firstName == null) {
                this.lastName = lastName;                                    if (other.firstName != null)
            }                                                                    return false;
                                                                         } else if (!firstName.equals(other.firstName))
            public String getFirstName() {                                   return false;
                return firstName;                                        if (lastName == null) {
            }                                                                if (other.lastName != null)
                                                                                 return false;
            public String getLastName() {                                } else if (!lastName.equals(other.lastName))
                return lastName;                                             return false;
            }                                                            return true;
                                                                     }
            @Override
            public int hashCode() {                                  @Override
                final int prime = 31;                                public String toString() {
                int result = 1;                                          return "Person(firstName:" + firstName
                result = prime * result + ((firstName == null)               + ", lastName:" + lastName + ")";
                    ? 0 : firstName.hashCode());                     }
                result = prime * result + ((lastName == null)
                    ? 0 : lastName.hashCode());                  }
                return result;
            }

            @Override
            public boolean equals(Object obj) {
                if (this == obj)
                    return true;


                                                                                                              Java
                                                                                   2011 05/28
                 Slide # 16
2011    5   28
public final class Person {                                       if (obj == null)
           private final String firstName;                                   return false;
           private final String lastName;                                if (getClass() != obj.getClass())
                                                                             return false;
            public Person(String firstName, String lastName) {           Person other = (Person) obj;
                this.firstName = firstName;                              if (firstName == null) {
                this.lastName = lastName;                                    if (other.firstName != null)
            }                                                                    return false;
                                                                         } else if (!firstName.equals(other.firstName))
            public String getFirstName() {                                   return false;
                return firstName;                                        if (lastName == null) {
            }                                                                if (other.lastName != null)
                                                                                 return false;
            public String getLastName() {                                } else if (!lastName.equals(other.lastName))
                return lastName;                                             return false;
            }                                                            return true;
                                                                     }
            @Override
            public int hashCode() {                                  @Override
                final int prime = 31;                                public String toString() {
                int result = 1;                                          return "Person(firstName:" + firstName
                result = prime * result + ((firstName == null)               + ", lastName:" + lastName + ")";
                    ? 0 : firstName.hashCode());                     }
                result = prime * result + ((lastName == null)
                    ? 0 : lastName.hashCode());                  }
                return result;
            }

            @Override
            public boolean equals(Object obj) {
                if (this == obj)
                    return true;


                                                                                                              Java
                                                                                   2011 05/28
                 Slide # 16
2011    5   28
Groovy                           :4

           @Immutable
           class Person {
               String firstName, lastName
           }




                                                      Java
                                        2011 05/28
                Slide # 17
2011   5   28
Groovy                        :4

           @Immutable
           class Person {
               String firstName, lastName
           }

           x = new Person("Junji","Uehara")
           assert x.lastName == "Uehara"
           x.firstName = "abc"
           //==>
           groovy.lang.ReadOnlyPropertyException:
           Cannot set readonly property: firstName
                                                      Java
           for class: Person             2011 05/28
                Slide # 17
2011   5   28
Groovy                           :4

           @Immutable
           class Person {
               String firstName, lastName
           }

           x = new Person("Junji","Uehara")
           assert x.lastName == "Uehara"
           x.firstName = "abc"



                                                      Java
                                        2011 05/28
                Slide # 18
2011   5   28
Groovy                           :4

           @Immutable
           class Person {
               String firstName, lastName
           }

           x = new Person("Junji","Uehara")
           assert x.lastName == "Uehara"
           x.firstName = "abc"



                                                      Java
                                        2011 05/28
                Slide # 19
2011   5   28
Groovy                           :4

           @Immutable
           class Person {
               String firstName, lastName
           }

           x = new Person("Junji","Uehara")
           assert x.lastName == "Uehara"
           x.firstName = "abc"



                                                      Java
                                        2011 05/28
                Slide # 20
2011   5   28
Java
                             2011 05/28
                Slide # 21
2011   5   28
Java
                             2011 05/28
                Slide # 21
2011   5   28
Java
                             2011 05/28
                Slide # 21
2011   5   28
Java
                             2011 05/28
                Slide # 21
2011   5   28
Java
                             2011 05/28
                Slide # 21
2011   5   28
DSL
                             OS


                                                   PHP     Haskel
                                  C++
                                                  Python
                              C                    Ruby
                                         Java


                                        Java + Groovy
                                                                          Java
                                                             2011 05/28
                Slide # 22
2011   5   28
Groovy
   Java

                                          Java
                             2011 05/28
                Slide # 23
2011   5   28

More Related Content

What's hot (20)

Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
intelliyole
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
RichardWarburton
 
Kotlin, why?
Kotlin, why?Kotlin, why?
Kotlin, why?
Paweł Byszewski
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
Mario Fusco
 
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forwardJava 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
Mario Fusco
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Java generics final
Java generics finalJava generics final
Java generics final
Akshay Chaudhari
 
Java VS Python
Java VS PythonJava VS Python
Java VS Python
Simone Federici
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
Trisha Gee
 
Functional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting LambdasFunctional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting Lambdas
Ganesh Samarthyam
 
Unit testing concurrent code
Unit testing concurrent codeUnit testing concurrent code
Unit testing concurrent code
Rafael Winterhalter
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
Scott Leberknight
 
java sockets
 java sockets java sockets
java sockets
Enam Ahmed Shahaz
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
DEVTYPE
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
Alok Kumar
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
Sunil OS
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
julien.ponge
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
julien.ponge
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
intelliyole
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
RichardWarburton
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
Mario Fusco
 
Java 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forwardJava 7, 8 & 9 - Moving the language forward
Java 7, 8 & 9 - Moving the language forward
Mario Fusco
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
Trisha Gee
 
Functional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting LambdasFunctional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting Lambdas
Ganesh Samarthyam
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
DEVTYPE
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
Alok Kumar
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
Sunil OS
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
julien.ponge
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
julien.ponge
 

Viewers also liked (6)

GroovyConsole
GroovyConsoleGroovyConsole
GroovyConsole
Kiyotaka Oku
 
Letsgo sendai nobusue_20110528
Letsgo sendai nobusue_20110528Letsgo sendai nobusue_20110528
Letsgo sendai nobusue_20110528
Nobuhiro Sue
 
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
Yasuharu Nakano
 
「プログラミングGroovy」Groovyってなんだろ?編
「プログラミングGroovy」Groovyってなんだろ?編「プログラミングGroovy」Groovyってなんだろ?編
「プログラミングGroovy」Groovyってなんだろ?編
Kazuchika Sekiya
 
Grails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLTGrails 1.4.0.M1 メモLT
Grails 1.4.0.M1 メモLT
Tsuyoshi Yamamoto
 
スプリント計画ミーティング
スプリント計画ミーティングスプリント計画ミーティング
スプリント計画ミーティング
Miho Nagase
 
Letsgo sendai nobusue_20110528
Letsgo sendai nobusue_20110528Letsgo sendai nobusue_20110528
Letsgo sendai nobusue_20110528
Nobuhiro Sue
 
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
Yasuharu Nakano
 
「プログラミングGroovy」Groovyってなんだろ?編
「プログラミングGroovy」Groovyってなんだろ?編「プログラミングGroovy」Groovyってなんだろ?編
「プログラミングGroovy」Groovyってなんだろ?編
Kazuchika Sekiya
 
スプリント計画ミーティング
スプリント計画ミーティングスプリント計画ミーティング
スプリント計画ミーティング
Miho Nagase
 

Similar to Let's go Developer 2011 sendai Let's go Java Developer (Programming Language Groovy Part) (20)

Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Matthew Farwell
 
Java Collections
Java CollectionsJava Collections
Java Collections
rithustutorials
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
arjuncorner565
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
fantoosh1
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
Peter Pilgrim
 
Fee managment system
Fee managment systemFee managment system
Fee managment system
fairy9912
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
Mohsen Zainalpour
 
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
Henri Tremblay
 
Works Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay ChauhanWorks Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay Chauhan
Chinmay Chauhan
 
Elementary Sort
Elementary SortElementary Sort
Elementary Sort
Sri Prasanna
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
Rafael Winterhalter
 
Array list
Array listArray list
Array list
vishal choudhary
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
David Gómez García
 
Jug java7
Jug java7Jug java7
Jug java7
Dmitry Buzdin
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
elliando dias
 
EMFPath
EMFPathEMFPath
EMFPath
mikaelbarbero
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
Cloudera, Inc.
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
Rafael Casuso Romate
 
Collection and framework
Collection and frameworkCollection and framework
Collection and framework
SARAVANAN GOPALAKRISHNAN
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Matthew Farwell
 
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdfModify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
arjuncorner565
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
fantoosh1
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
Peter Pilgrim
 
Fee managment system
Fee managment systemFee managment system
Fee managment system
fairy9912
 
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
OracleCode One 2018: Java 5, 6, 7, 8, 9, 10, 11: What Did You Miss?
Henri Tremblay
 
Works Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay ChauhanWorks Applications Test - Chinmay Chauhan
Works Applications Test - Chinmay Chauhan
Chinmay Chauhan
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
Rafael Winterhalter
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
David Gómez García
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
Rafael Casuso Romate
 

More from Uehara Junji (20)

Use JWT access-token on Grails REST API
Use JWT access-token on Grails REST APIUse JWT access-token on Grails REST API
Use JWT access-token on Grails REST API
Uehara Junji
 
Groovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUGGroovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUG
Uehara Junji
 
Groovy Shell Scripting 2015
Groovy Shell Scripting 2015Groovy Shell Scripting 2015
Groovy Shell Scripting 2015
Uehara Junji
 
Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418
Uehara Junji
 
Markup Template Engine introduced Groovy 2.3
Markup Template Engine introduced Groovy 2.3Markup Template Engine introduced Groovy 2.3
Markup Template Engine introduced Groovy 2.3
Uehara Junji
 
Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait
Uehara Junji
 
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ckIndy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Uehara Junji
 
enterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summerenterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summer
Uehara Junji
 
New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1
Uehara Junji
 
Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309
Uehara Junji
 
Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)
Uehara Junji
 
groovy 2.1.0 20130118
groovy 2.1.0 20130118groovy 2.1.0 20130118
groovy 2.1.0 20130118
Uehara Junji
 
New feature of Groovy2.0 G*Workshop
New feature of Groovy2.0 G*WorkshopNew feature of Groovy2.0 G*Workshop
New feature of Groovy2.0 G*Workshop
Uehara Junji
 
G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901
Uehara Junji
 
JJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/GrailsJJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/Grails
Uehara Junji
 
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Uehara Junji
 
Java x Groovy: improve your java development life
Java x Groovy: improve your java development lifeJava x Groovy: improve your java development life
Java x Groovy: improve your java development life
Uehara Junji
 
Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224
Uehara Junji
 
Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)
Uehara Junji
 
GroovyServ concept, how to use and outline.
GroovyServ concept, how to use and outline.GroovyServ concept, how to use and outline.
GroovyServ concept, how to use and outline.
Uehara Junji
 
Use JWT access-token on Grails REST API
Use JWT access-token on Grails REST APIUse JWT access-token on Grails REST API
Use JWT access-token on Grails REST API
Uehara Junji
 
Groovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUGGroovy Bootcamp 2015 by JGGUG
Groovy Bootcamp 2015 by JGGUG
Uehara Junji
 
Groovy Shell Scripting 2015
Groovy Shell Scripting 2015Groovy Shell Scripting 2015
Groovy Shell Scripting 2015
Uehara Junji
 
Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418Shibuya JVM Groovy 20150418
Shibuya JVM Groovy 20150418
Uehara Junji
 
Markup Template Engine introduced Groovy 2.3
Markup Template Engine introduced Groovy 2.3Markup Template Engine introduced Groovy 2.3
Markup Template Engine introduced Groovy 2.3
Uehara Junji
 
Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait Introduce Groovy 2.3 trait
Introduce Groovy 2.3 trait
Uehara Junji
 
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ckIndy(Invokedynamic) and Bytecode DSL and Brainf*ck
Indy(Invokedynamic) and Bytecode DSL and Brainf*ck
Uehara Junji
 
enterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summerenterprise grails challenge, 2013 Summer
enterprise grails challenge, 2013 Summer
Uehara Junji
 
New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1New features of Groovy 2.0 and 2.1
New features of Groovy 2.0 and 2.1
Uehara Junji
 
Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309Groovy kisobenkyoukai20130309
Groovy kisobenkyoukai20130309
Uehara Junji
 
Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)Read Groovy Compile process(Groovy Benkyoukai 2013)
Read Groovy Compile process(Groovy Benkyoukai 2013)
Uehara Junji
 
groovy 2.1.0 20130118
groovy 2.1.0 20130118groovy 2.1.0 20130118
groovy 2.1.0 20130118
Uehara Junji
 
New feature of Groovy2.0 G*Workshop
New feature of Groovy2.0 G*WorkshopNew feature of Groovy2.0 G*Workshop
New feature of Groovy2.0 G*Workshop
Uehara Junji
 
G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901G* Workshop in fukuoka 20120901
G* Workshop in fukuoka 20120901
Uehara Junji
 
JJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/GrailsJJUG CCC 2012 Real World Groovy/Grails
JJUG CCC 2012 Real World Groovy/Grails
Uehara Junji
 
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Java One 2012 Tokyo JVM Lang. BOF(Groovy)
Uehara Junji
 
Java x Groovy: improve your java development life
Java x Groovy: improve your java development lifeJava x Groovy: improve your java development life
Java x Groovy: improve your java development life
Uehara Junji
 
Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224Jggug ws 15th LT 20110224
Jggug ws 15th LT 20110224
Uehara Junji
 
Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)Easy Going Groovy(Groovyを気軽に使いこなそう)
Easy Going Groovy(Groovyを気軽に使いこなそう)
Uehara Junji
 
GroovyServ concept, how to use and outline.
GroovyServ concept, how to use and outline.GroovyServ concept, how to use and outline.
GroovyServ concept, how to use and outline.
Uehara Junji
 

Recently uploaded (20)

Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
AI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdfAI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdf
Precisely
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
The Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI IntegrationThe Future of Cisco Cloud Security: Innovations and AI Integration
The Future of Cisco Cloud Security: Innovations and AI Integration
Re-solution Data Ltd
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
Does Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should KnowDoes Pornify Allow NSFW? Everything You Should Know
Does Pornify Allow NSFW? Everything You Should Know
Pornify CC
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
AI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdfAI You Can Trust: The Critical Role of Governance and Quality.pdf
AI You Can Trust: The Critical Role of Governance and Quality.pdf
Precisely
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 

Let's go Developer 2011 sendai Let's go Java Developer (Programming Language Groovy Part)

  • 1. Groovy Java 2011 5 28
  • 2. Java 2011 05/28 Slide # 2 2011 5 28
  • 3. Java 2011 05/28 Slide # 3 2011 5 28
  • 4. $ cat input.txt That that is is that that is not is not is that it it is $ java WordCount input.txt 1: [That] 2: [not] 2: [it] 4: [that] 6: [is] Java 2011 05/28 Slide # 4 2011 5 28
  • 5. Java WordCount:48      Set<Map.Entry<String, Integer>> entrySet = import java.util.Comparator; map.entrySet(); import java.util.HashMap;      Object[] list = entrySet.toArray(); import java.util.Map;     Comparator comp = new Comparator(){ import java.util.Set;        public int compare(Object o1, Object o2) import java.util.List; { import java.util.Arrays;          Map.Entry<String, Integer> e1 = import java.io.FileReader; (Map.Entry<String, Integer>) o1; import java.io.BufferedReader;          Map.Entry<String, Integer> e2 = import java.io.FileNotFoundException; (Map.Entry<String, Integer>) o2; import java.io.IOException;         return e1.getValue() - e2.getValue();         } public class WordCount {       };   @SuppressWarnings(value = "unchecked")       Arrays.sort(list, comp);   public static void main(String[] args) {       for (Object it: list) {     FileReader fis = null;         Map.Entry<String, Integer> entry =     BufferedReader br = null; (Map.Entry<String, Integer>)it;     try {         System.out.println(entry.getValue() + ":       HashMap<String, Integer> map = new ["+entry.getKey()+"]"); HashMap<String, Integer>();       }       fis = new FileReader(args[0]);     }       br = new BufferedReader(fis);     catch (IOException e) {       String line;       try {if (br != null) br.close();}catch       while ((line = br.readLine()) != null) { (IOException ioe){}         for (String it: line.split("s+")) {       try {if (fis != null)fis.close();}catch          map.put(it, (map.get(it)==null) ? 1 : (IOException ioe){} (map.get(it) + 1));       e.printStackTrace();         }     } Java       }   } } 2011 05/28 Slide # 5 2011 5 28
  • 6. Groovy WordCount(9 ) def map = [:].withDefault{0} new File(args[0]).eachLine {   it.split(/s+/).each {     map[it]++    } } map.entrySet().sort{it.value}.each {   println "${it.value}: [${it.key}]" } Java 2011 05/28 Slide # 6 2011 5 28
  • 7. Java             Set<Map.Entry<String, Integer>> import java.util.Comparator; entrySet = map.entrySet(); import java.util.HashMap;             Object[] list = entrySet.toArray(); import java.util.Map;             Comparator comp = new Comparator(){ import java.util.Set;                 public int compare(Object o1, import java.util.List; Object o2) { import java.util.Arrays;                     Map.Entry<String, Integer> e1 import java.io.FileReader; = (Map.Entry<String, Integer>) o1; import java.io.BufferedReader;                     Map.Entry<String, Integer> e2 import java.io.FileNotFoundException; = (Map.Entry<String, Integer>) o2; import java.io.IOException;                     return e1.getValue() - e2.getValue(); public class WordCount {                 }     @SuppressWarnings(value = "unchecked")             };     public static void main(String[] args) {             Arrays.sort(list, comp);         FileReader fis = null;             for (Object it: list) {         BufferedReader br = null;                 Map.Entry<String, Integer> entry         try { = (Map.Entry<String, Integer>)it;             HashMap<String, Integer> map = new                 System.out.println(entry.getValue HashMap<String, Integer>(); () + ": ["+entry.getKey()+"]");             fis = new FileReader(args[0]);             }             br = new BufferedReader(fis);         }             String line;         catch (IOException e) {             while ((line = br.readLine()) !=             try {if (br != null) br.close();} null) { catch(IOException ioe){}                 for (String it: line.split("s             try {if (fis != null)fis.close();} +")) { catch(IOException ioe){}                     map.put(it, (map.get(it)             e.printStackTrace(); ==null) ? 1 : (map.get(it) + 1));                 }         }     } Java             } } 2011 05/28 Slide # 7 2011 5 28
  • 8. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 8 2011 5 28
  • 9. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 9 2011 5 28
  • 10. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 10 2011 5 28
  • 11. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 11 2011 5 28
  • 12. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 12 2011 5 28
  • 13. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 13 2011 5 28
  • 14. Groovy WordCount(9 ) def map = [:].withDefault{0} // value 0 map new File(args[0]).eachLine { //   it.split(/s+/).each {     // /s+/     map[it]++                // map 1   } } map.entrySet().sort{it.value}.each {// map entrySet value   println "${it.value}: [${it.key}]"// key,value } Java 2011 05/28 Slide # 14 2011 5 28
  • 15. Java 2011 05/28 Slide # 15 2011 5 28
  • 16. public final class Person { if (obj == null) private final String firstName; return false; private final String lastName; if (getClass() != obj.getClass()) return false; public Person(String firstName, String lastName) { Person other = (Person) obj; this.firstName = firstName; if (firstName == null) { this.lastName = lastName; if (other.firstName != null) } return false; } else if (!firstName.equals(other.firstName)) public String getFirstName() { return false; return firstName; if (lastName == null) { } if (other.lastName != null) return false; public String getLastName() { } else if (!lastName.equals(other.lastName)) return lastName; return false; } return true; } @Override public int hashCode() { @Override final int prime = 31; public String toString() { int result = 1; return "Person(firstName:" + firstName result = prime * result + ((firstName == null) + ", lastName:" + lastName + ")"; ? 0 : firstName.hashCode()); } result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); } return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; Java 2011 05/28 Slide # 16 2011 5 28
  • 17. public final class Person { if (obj == null) private final String firstName; return false; private final String lastName; if (getClass() != obj.getClass()) return false; public Person(String firstName, String lastName) { Person other = (Person) obj; this.firstName = firstName; if (firstName == null) { this.lastName = lastName; if (other.firstName != null) } return false; } else if (!firstName.equals(other.firstName)) public String getFirstName() { return false; return firstName; if (lastName == null) { } if (other.lastName != null) return false; public String getLastName() { } else if (!lastName.equals(other.lastName)) return lastName; return false; } return true; } @Override public int hashCode() { @Override final int prime = 31; public String toString() { int result = 1; return "Person(firstName:" + firstName result = prime * result + ((firstName == null) + ", lastName:" + lastName + ")"; ? 0 : firstName.hashCode()); } result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); } return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; Java 2011 05/28 Slide # 16 2011 5 28
  • 18. Groovy :4 @Immutable class Person { String firstName, lastName } Java 2011 05/28 Slide # 17 2011 5 28
  • 19. Groovy :4 @Immutable class Person { String firstName, lastName } x = new Person("Junji","Uehara") assert x.lastName == "Uehara" x.firstName = "abc" //==> groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: firstName Java for class: Person 2011 05/28 Slide # 17 2011 5 28
  • 20. Groovy :4 @Immutable class Person { String firstName, lastName } x = new Person("Junji","Uehara") assert x.lastName == "Uehara" x.firstName = "abc" Java 2011 05/28 Slide # 18 2011 5 28
  • 21. Groovy :4 @Immutable class Person { String firstName, lastName } x = new Person("Junji","Uehara") assert x.lastName == "Uehara" x.firstName = "abc" Java 2011 05/28 Slide # 19 2011 5 28
  • 22. Groovy :4 @Immutable class Person { String firstName, lastName } x = new Person("Junji","Uehara") assert x.lastName == "Uehara" x.firstName = "abc" Java 2011 05/28 Slide # 20 2011 5 28
  • 23. Java 2011 05/28 Slide # 21 2011 5 28
  • 24. Java 2011 05/28 Slide # 21 2011 5 28
  • 25. Java 2011 05/28 Slide # 21 2011 5 28
  • 26. Java 2011 05/28 Slide # 21 2011 5 28
  • 27. Java 2011 05/28 Slide # 21 2011 5 28
  • 28. DSL OS PHP Haskel C++ Python C Ruby Java Java + Groovy Java 2011 05/28 Slide # 22 2011 5 28
  • 29. Groovy Java Java 2011 05/28 Slide # 23 2011 5 28
  翻译: