Operators are special symbols that give us the language to interact with one or two operations and return a result, based on the type of operator we use, we'll see if it works with a single operating or are both required. As we have done until now present a list of different types of operators and then go into the details of each.
<]
Operators:
Arithmetic Operators Assignment Operators Unary Operators Equality and Relational Operators Conditional Operators
- Assignment Operators This is one of the operators common that we find, basically used for mapping between the variables and we want to store data in it. This operator is represented by the symbol "=".
- var example1 = 2; var example2 = "Test";
- In this case we see two assignments in Example 1 save the value 2 in the example1 variable, and in the second case the string example2 (Actually talk to keep the references and that are objects, but I think it is important to want to leave this issue as clear).
-
Arithmetic Operators Arithmetic operators are used for calculations between the variables. + (additive operator)
* (multiplication operator) / (division operator) mod (remainder operator) These operators cover the 4 basic operations and operation the rest through the switch mod
Example var
example = 1 + 2; println (example) / / example is 3 example = example - 1; println (example) / / example
example is 2 * 2 = example,
println (example) / / example is 4
example = example / 2;
println (example) / / example is 2
example = example + 8;
println (example) / / example is 10
example = example mod 7; println (example) / / example is 3
Operators Unary Operators Unary are those that can be used having a single operand.
example = 0;
example + = 1;
println (example) / / result is 1 example
-= 1;
println (example) / / result is 0
example = 2;
example *= 5;
println (example) / / result is 10
example / = 2; println (example) / / result is 5 Equality and Relational Operators
Here are the operators we use to comparisons and relationships of the type, is larger than it is different than, etc..
== / / Same as
! = / / Other than that
> / / Greater than
> = \u200b\u200b/ / Greater than or equal
\u0026lt;/ / Less than
\u0026lt;= / / Less than or equal
def num1 = 1;
def num2 = 2;
println (num1 == num2) / / False
println (num1! = num2) / / True
println (num1> num2) / / False println (num1> = num2) / / False println (num1 \u0026lt;num2) / / True println (num1 \u0026lt;= num2) / / True Conditional Operators
In this section we have two operators for these conditions are the operator AND and OR operators, they have a behavior called "Short-circuiting" which means that if an expression we use the AND operator and the first term is false and is left to assess the rest, and if we use an OR operator if the first term is true also evaluates the rest .
def username = "foo";
def password = "bar";
if ((username == "foo") and (password == "bar")) {
println ("Test 1: username AND Are correct password ") / / Test 1: Are correct username and password
} if ((username ==" ") and (password ==" bar ")) {
println (" Test 2: username AND password is correct ") / / does not run this code
} if ((username == "foo") or (password == "bar")) { println ("Test 3: OR username password is correct") / / Test 3: OR username password is correct } if ((username == "") or (password == "bar")) {println ("Test 4: OR username password is correct") / / Test 4: OR username password is correct}
Type Comparison Operator This operator is used to check whether an object is an instance of a class or subclass in particular. The instanceof operator returns true if the object is an instance of the specified class. Returns false if the object is an instance of the specified class, or if the object is null. Def
str1 = "Hello";
println (str1 instanceof String) / / True
def num = 1031;
println (num instanceof Integer) / / False
Well this was a quick review of the JavaFX operators now and then continue to see binding sequences and triggers between functions introduced in order to leave the plot of this powerful scripting language.
Greetings until next
0 comments:
Post a Comment