Guest User

Untitled

a guest
Jan 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. )
  6.  
  7. type Human struct {
  8. Name string
  9. Age int
  10. }
  11.  
  12. func (h Human) showHuman() {
  13. fmt.Printf("Name: %v, Age: %v", h.Name, h.Age)
  14. }
  15.  
  16. func main() {
  17. h := Human{
  18. Name: "qushot",
  19. Age: 23,
  20. }
  21.  
  22. h.showHuman()
  23. }
  24.  
  25. // Java
  26. // public class Example {
  27. // private String name;
  28. // private int age;
  29. //
  30. // public void showHuman(String name, int age) {
  31. // System.out.println("Name: " + name + ", Age: " + age);
  32. // }
  33. //
  34. // public void setName(String name) {
  35. // this.name = name;
  36. // }
  37. // public String getName() {
  38. // return name;
  39. // }
  40. // public void setAge(int age) {
  41. // this.age = age;
  42. // }
  43. // public int getAge() {
  44. // return age;
  45. // }
  46. // }
  47.  
  48. // public class Main {
  49. // public static void main(String[] args) {
  50. // Example example = new Example();
  51. // example.setName("qushot");
  52. // example.setAge(23);
  53. //
  54. // example.showHuman(example.getName(), example.getAge());
  55. // }
  56. // }
Add Comment
Please, Sign In to add comment