Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Tuesday

JAVA PROGRAMMING TUTORIAL 47 : ENUMERATION

//enum is used to declare constants

public class HackDefence{

public enum DipankarChoudhuryLab{

me("India"),he("usa");

private final String cntry;

DipankarChoudhuryLab(String country){

cntry = country;

}

public String getCountryName(){

return cntry;

     }

}

public static void main(String[]args){

System.out.println("Name "+" Country");

        for(DipankarChoudhuryLab name: DipankarChoudhuryLab.values()) {
 
    System.out.printf("%s\t%s\t\n", name, name.getCountryName());

      }

}

}
(my facebook profile link: https://www.facebook.com/dipankar.choudhury1)

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...