I am trying to create a data validation program that checks if a specific data type is valid by running each "type" (eg. name, age, gender) through its own validation method (each method is unique to its data type), the only problem is I want the application to be flexible to different data types and different amounts of data types.

Is there a way I can actually generate an entirely new Java application with methods for each type from the running Java application (for example "writing" a new class) during runtime once I have all the types?

Example Code:

```
public class JavaGen(){
    public static void main(String[] args){

        int dataLength = Integer.parseInt(JOptionPane.showInputDialog("Amount Of Data Types:"));
        String[] dataTypeList = new String[dataLength];

        //Fill up dataTypeList with user input
        writeJavaFile(dataTypeList);
    }

    public void writeJavaFile(String[] dataTypes){
        //Create the new class and its methods here using the array of dataTypes
    }
}

```

Which, for example, will then create a class of methods similar to this:

```
public class ActualClass(){
    public String validate'What The dataTypes[x] was'(String infoToValidate){
        if(etc etc){
            return "etc etc";
        }else{
            return "";
        }
    }
}

```