How to use Enum in Java Tutorial using Net beans IDE

This tutorial is all about How to use Enum in Java Tutorial using Net beans IDE. In this tutorial you will learn How to use Enum in Java Tutorial using Net beans IDE.

Enum is short for enumeration, basically it’s a way to encapsulate a data type like for example if you have bunch of data type and the better way to encapsulate your data is by using enum.

Enum can be created inside of a class or outside of a class but in this tutorial we were using enum inside the class. This tutorial uses Net beans IDE.

Please follow all the steps below to complete this tutorial.

How to use Enum in Java Tutorial using Net beans IDE steps

Create your project by clicking file at the top of your project and then click new project, you can name your project whatever you want. After that you create a class by right clicking the source packages and new java class.

You can name your class whatever you want. Then copy paste the code below:

[Java]

public class EnumDemo {




enum State {

COMPLETED, ONGOING, PENDING;

}




public static void main (String [] args) {




State stateObject1 = State.COMPLETED;

State stateObject2 = State.ONGOING;

State stateObject3 = State.PENDING;




System.out.println (stateObject1);




// the output will be: COMPLETED

}




}

[/java]

Then you’re done. Run your project and see if it works.

About How To Use Enum In Java

Project Name:How To Use Enum
Language/s Used:JAVA
Database:None
Type:Desktop Application
Developer:IT SOURCECODE
Updates:0

How To Use Enum In Java– Project Information

For questions or any other concerns or thesis/capstone creation with documentation, you can contact me through the following:

E-Mail: [email protected]

Facebook: facebook.com/RyyanSalem

Contact No.: +639098911050

Ryan A. Salem

BSIT Graduate, soon to be MIT.

Java Developer / System Developer

Related topic(s) that you make like:

1.) How to use toString Method in Java Tutorial usng Netbeans
2.) How to use Keyword Static in Java Tutorial using Netbeans IDE

Leave a Comment