Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getArgument(String[] args, int index, String defaultValue) {
        if (args == null || args.length <= index)
            return defaultValue;

        if (args[index] == null)
            return defaultValue;

        return args[index];
    }

    public static int getArgument(String[] args, int index, int defaultValue) {
        if (args == null || args.length <= index)
            return defaultValue;

        int retValue = defaultValue;
        try {
            retValue = Integer.valueOf(args[index]);
        } catch (NumberFormatException e) {
            retValue = defaultValue;
        }

        return retValue;
    }
}