arrays - How to call your enum using a for or while method in java.? -
so trying use or while method, print out of objects in main method.(anna, courtney, ashley)
public class javaapplication56 { public enum details { anna(" blue ", " blue"), courtney(" red", " black"), ashley(" yellow ", " green"); string haircolor; string eyecolor; details(string haircolor, string eyecolor) { this.haircolor = haircolor; this.eyecolor = eyecolor; } public string gethair() { return haircolor; } public string geteye() { return eyecolor; } }
i getting error under main method says bad operand type binary operator. first type int, second type details[].
public static void main(string[] args) { javaapplication56 ja = new javaapplication56(); (int person = 0; person < details.values(); person++) { system.out.println(details.values()+details.); } } }
or more simply:
// details should re-named details (details detail : details.values()) { system.out.println(detail); // have tostring() override? }
Comments
Post a Comment