How to Check if an Argument Exists in Java

When dealing with functions in Java, the values that are contained within the functions are called the "arguments" of the function. A function can contain an unlimited number of arguments. These arguments contain variables that are passed from outside the function into the function itself. If you need to check whether these arguments are empty or not, you can do so with some simple checks in Java code.

Instructions

    • 1

      Use your Java coding tool to open your Java application.

    • 2

      Locate the place in your code that contains the function whose arguments you want to check.

    • 3

      Type inside the function on the first line, "if(exists(fn_name($arg1))){ condition_one} else { condition_two}". In this example code, "fn_name" is the name of the function you are checking, "$arg1" is the argument you are checking, "condition_one" is what you want the code to do if the argument exists and "condition_two" is what you want the code to do if the argument does not exist.

Related Searches:

Comments

Related Ads

Featured