Previous Topic Next topic Print topic


Program Structure - in COBOL and Java

COBOL Java
class-id MicroFocus.Examples.HelloWorld.
*> member variable
01 field1           binary-long. 

method-id Main static(args as string occurs any).
    declare nam as string = "Bob"
    *> See if an argument was passed from the command line
    if size of args > 0
        set nam to args[0] *> [] means 0 based index
    end-if
end method.

end class.
public class program_structure
{
    // Member variable 
    private String field1 ;
    
    public static void main(String[] args)
    {
        String nam = "Bob"; 
        // See if an argument was passed from the command line
        if (args.length > 0)
            nam = args[0]; 

    }

}

Portions of these examples were produced by Dr. Frank McCown, Harding University Computer Science Dept, and are licensed under a Creative Commons License.

Previous Topic Next topic Print topic