Skip to content

Is there any way to write this small piece of code in java? [closed]

I am unable to understand the below code so, Is there any way to write this piece of code in java (Easy Manner)? Someone told me it is using the concept of multithreading? Is it true?

Thanks for helping me in advance!

fileTypeList.forEach( fileExtension -> parseFileInfo( (JSONObject) fileExtension ) );

This is the method for parseFileInfo:

private static void parseFileInfo(JSONObject file) {
        String extension = (String) file.get("Extension");
        String category = (String) file.get("Category");
        String type = (String) file.get("Type");
        String description = (String) file.get("Description");
        String programs = (String) file.get("Programs");



fileTypeList.forEach( fileExtension -> parseFileInfo( (JSONObject) fileExtension ) );

For every fileExtension in fileTypeList parseFileInfo is called to perform intended task.

You can easily write a for each loop for this logic.

for(FileExtension fileExtension : fileTypeList) {
    parseFileInfo((JSONObject) fileExtension)
// I have assumed `FileExtension` as a type of `fileTypeList` list.