Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class c {
- //Vars
- //-Klassvars
- public static int totAntal;
- //-Instansvars
- public int cID;
- //Konstruktorer
- public c() {
- totAntal++;
- this.cID = totAntal;
- }
- //Metoder
- //-KlassMetoder
- public static void Total() {
- System.out.println(c.totAntal);
- }
- //-InstansMetoder
- public int CheckID() {
- return cID;
- }
- }
- public class Sid130 {
- public static void main(String []args) {
- c c1 = new c();
- c c2 = new c();
- c c3 = new c();
- c.Total();
- c c4 = new c();
- c c5 = new c();
- c.Total();
- System.out.println("ID #1 = " + c1.CheckID());
- System.out.println("ID #4 = " + c4.CheckID());
- System.out.println("ID #5 = " + c5.CheckID());
- }
- }
Add Comment
Please, Sign In to add comment