August 28, 2019

How to Convert Array to ArrayList & Enum Example in Java

/**
 *
 */
package com.konzern.transformatore.enums;

/**
 * @author konzernites
 * @version 1.0
 *
 */
public enum CobolDivision {

IDENTIFICATION_DIVISION("IDENTIFICATION DIVISION."),
DATA_DIVISION("DATA DIVISION."),
PROCEDURE_DIVISION("PROCEDURE DIVISION."),
ENVIRONMENT_DIVISION("ENVIRONMENT DIVISION.");

private String division = null;

private CobolDivision(String division) {
this.division= division;
}

public String getDivision() {
return division;
}


}


import java.util.ArrayList;
import java.util.List;

import com.konzern.transformatore.enums.CobolDivision;

/**
 * 8281808029
 */

/**
 * @author Consumerfed
 * 
 *
 */
public class EnumsTestClass {

/**
* @param args
*/
public static void main(String[] args) {

List<String> cobolDivisions = new ArrayList<>();

for (CobolDivision cobolDivison : CobolDivision.values()) {
cobolDivisions.add(cobolDivison.getDivision());
System.out.println(cobolDivison.getDivision());
}
System.out.println(cobolDivisions.size());

}

}


Output

IDENTIFICATION DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
ENVIRONMENT DIVISION.
4


Tik Toc Toe in python, two player game, playing with computer complete source code available soon...



Amazon choice the best affordable mobile smart phone

No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments