How to use this in Java

1 Answer

0 votes
class Worker {
    public int id;
    public String name;
  
    public Worker(int _id, String s) {
        this.id = _id;
        this.name = s;
    }
    public void Show() {
        System.out.println("ID = " + id + " : " + "Name = " + name);
    }
}

public class MyClass {
    public static void main(String args[]) {
        Worker w = new Worker(75763, "Dumbledore");
        
        w.Show();
    }
}




/*
run:

ID = 75763 : Name = Dumbledore

*/

 



answered Dec 12, 2020 by avibootz

Related questions

1 answer 159 views
1 answer 175 views
1 answer 165 views
1 answer 161 views
1 answer 174 views
174 views asked Jul 25, 2019 by avibootz
2 answers 196 views
196 views asked Jul 5, 2017 by avibootz
...