Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- )
- type Human struct {
- Name string
- Age int
- }
- func (h Human) showHuman() {
- fmt.Printf("Name: %v, Age: %v", h.Name, h.Age)
- }
- func main() {
- h := Human{
- Name: "qushot",
- Age: 23,
- }
- h.showHuman()
- }
- // Java
- // public class Example {
- // private String name;
- // private int age;
- //
- // public void showHuman(String name, int age) {
- // System.out.println("Name: " + name + ", Age: " + age);
- // }
- //
- // public void setName(String name) {
- // this.name = name;
- // }
- // public String getName() {
- // return name;
- // }
- // public void setAge(int age) {
- // this.age = age;
- // }
- // public int getAge() {
- // return age;
- // }
- // }
- // public class Main {
- // public static void main(String[] args) {
- // Example example = new Example();
- // example.setName("qushot");
- // example.setAge(23);
- //
- // example.showHuman(example.getName(), example.getAge());
- // }
- // }
Add Comment
Please, Sign In to add comment