Click here to watch in Youtube :
https://www.youtube.com/watch?v=G3vaanejdDw&list=UUhwKlOVR041tngjerWxVccw
SiteInfo.java
https://sites.google.com/site/ramj2eev1/home/javabasics/EnumDemo_equal_to_op_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/EnumDemo_equal_to_op_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/45d5519a1474198166ac515ccd559cc996bb550c/BasicJava/EnumDemo_equal_to_op_App/?at=master
See also:
All JavaEE Viedos Playlist
All JavaEE Viedos
All JAVA EE Links
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
https://www.youtube.com/watch?v=G3vaanejdDw&list=UUhwKlOVR041tngjerWxVccw
SiteInfo.java
public enum SiteInfo { AMAZON("https://www.amazon.in/"), PAYTM("https://www.paytm.com"), SNAPDEAL("https://www.snapdeal.com/"); private String url; SiteInfo(String url) { this.url = url; } public String getUrl() { return url; } }EnumDemo.java
public class EnumDemo { public static void main(String[] args) { getSiteInfo(SiteInfo.SNAPDEAL); } private static void getSiteInfo(SiteInfo siteInfo) { /* * We can compare the Enum values using == operator. */ if (siteInfo == SiteInfo.AMAZON) { System.out.println("URL : " + siteInfo.getUrl()); } else if (siteInfo == SiteInfo.PAYTM) { System.out.println("URL : " + siteInfo.getUrl()); } else if (siteInfo == SiteInfo.SNAPDEAL) { System.out.println("URL : " + siteInfo.getUrl()); } else { System.out.println("Not a valid site..."); } } }Output
URL : https://www.snapdeal.com/Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/EnumDemo_equal_to_op_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/EnumDemo_equal_to_op_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/45d5519a1474198166ac515ccd559cc996bb550c/BasicJava/EnumDemo_equal_to_op_App/?at=master
See also:
No comments:
Post a Comment