narenarya

Java is becoming Burden for this generation

May 21st, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ######################## FLASH FLASH FLASH ############################
  2. See how Clojure is useful
  3. Small code in Java(really not small) to create a data structure called Book
  4. Class Book{
  5. String title;
  6. String author;
  7. public Book(String title,String author)
  8. {
  9. this.title=title;
  10. this.author=author;
  11. }
  12. String getTitle()
  13. {
  14. return title
  15. }
  16. String getAuthor()
  17. {
  18. return author
  19. }
  20. void setTitle(String title)
  21. this.title=title
  22. void setAuthor(String author)
  23. this.author=author
  24. }
  25. ########################################################################
  26. @@@@@@@@@@@@@@@@@@@@@@@@ NOW THE SAME CODE IN CLOJURE @@@@@@@@@@@@@@@@@@@
  27.  
  28. (defstruct Book :title :author)
  29.  
  30. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  31.  
  32. finally  both run on Java Virtual Machine,which one you think best.
Advertisement
Add Comment
Please, Sign In to add comment