How to Use Boolean Script

Boolean data types have two values, "true" and "false," to convey the truth of the logic based on Boolean Algebra. JavaScript programmers must present data as either being true or false, which is where the Boolean objects come in. You can use Boolean scripts in Java to compare which data needs to be used to execute a script or whether a component of a script will work. You can test Boolean objects in Java with a few simple codes.

Instructions

    • 1

      Construct a boolean object in your Java script by entering the following code: "boolean isTooLarge = true;." Boolean objects can only be true or false.

    • 2

      Create a test result to assign to your variable by typing the following code:

      String someText = "Here is a bit of text";

      if(someText.length()<60) isTooLarge = false;

      System.out.printlng("Too Large? " + isTooLarge);

      Click "Run" to run your program. This will test to see if the string length is too long and the result can be assigned to your boolean object.

    • 3

      Type the following script to assign the result from step 4 to your boolean object:

      public boolean isBelowMinimum(String testText) {

      boolean tooLarge = false;

      if(testText.length()<60) tooLarge = true;

      return tooLarge;

      }

Related Searches:

References

Comments

Related Ads

Featured