Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help needed with enum

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help needed with enum

    Hi there!

    First, I'm sorry if my post doesn't belong here, I registered today so I'm new here. I'm also french, so english is not my native language - sorry if I'm not precise and if you don't understand my message.

    I'm trying to create an enumeration called Origin with 3 parameters : a String (name), a list of Competence (which is a class that I created myself), and a list of Aspect (which I also created myself). I tried to create objects into this enumeration, but whatever I tried, I didn't manage to create one Origin. Here are some parts from my code, if you understood my explanation and have an element that might help me, thanks in advance!

    public enum Competence {
      Admin("Admin"),
      Medic("Medic"),
      Worker("Worker");
     
      private String name;
     
      Competence(String name) {
        this.name = name;
      }
    }
     
    public class Aspect {
      private String name;
     
      public Aspect(String name) {
        this.name = name;
      }
    }
     
    public enum Origin {
      Batra("Batra", "HERE IS THE Competence[]", "HERE IS THE Aspect[]");
     
      private String name;
      private Competence[] competences;
      private Aspect[] aspects;
     
      Origin(String name, Competence[] competences, Aspect[] aspects) {
        this.name = name;
        this.competences = competences;
        this.aspects = aspects;
      }
    }

    Once again, thank you in advance if you have an element that could help me progress in my personal project!

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help needed with enum

    There is an example for enum in the tutorial:
    https://docs.oracle.com/javase/tutor...vaOO/enum.html

    If you get error messages you need help with, copy the full text and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Enum Values Each Having Their Own Enum Values
    By corosus in forum Object Oriented Programming
    Replies: 1
    Last Post: July 5th, 2013, 07:04 AM
  2. Grails Developer Needed - URGENTLY NEEDED *WORK FROM HOME*
    By IngeniumR in forum Paid Java Projects
    Replies: 0
    Last Post: February 5th, 2013, 07:19 AM
  3. enum
    By anis.laghaei in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 23rd, 2012, 03:19 PM
  4. [SOLVED] Alternative to Enum
    By Doctor X in forum Java Theory & Questions
    Replies: 2
    Last Post: October 6th, 2012, 03:49 PM
  5. [SOLVED] Enum types, how does he know %s value?
    By beer-in-box in forum Java Theory & Questions
    Replies: 11
    Last Post: September 17th, 2011, 12:47 PM