improve guide/english/java/basic-operations (#33891)

added links, fixed indention
This commit is contained in:
David Schmidt
2019-01-18 04:49:59 +01:00
committed by Tom
parent e5366448cb
commit 95cd443efc

View File

@ -19,7 +19,6 @@ Java supports the following operations on variables:
* __Others__: `Conditional/Ternary(?:)`, `instanceof` * __Others__: `Conditional/Ternary(?:)`, `instanceof`
**Ternary because it work on the functionality of If Then Else i.e If condition is right then first alternative anotherwise the second one ** **Ternary because it work on the functionality of If Then Else i.e If condition is right then first alternative anotherwise the second one **
While most of the operations are self-explanatory, the Conditional (Ternary) Operator works as follows: While most of the operations are self-explanatory, the Conditional (Ternary) Operator works as follows:
`expression that results in boolean output ? return this value if true : return this value if false;` `expression that results in boolean output ? return this value if true : return this value if false;`
The Assignment operators (`+=`, `-=`, `*=`, `/=`, `%=`, `<<=`, `>>=`, `&=`, `^=`, `|=`) are just a short form which can be extended. The Assignment operators (`+=`, `-=`, `*=`, `/=`, `%=`, `<<=`, `>>=`, `&=`, `^=`, `|=`) are just a short form which can be extended.
@ -32,7 +31,6 @@ True Condition:
```java ```java
int x = 10; int x = 10;
int y = (x == 10) ? 5 : 9; // y will equal 5 since the expression x == 10 evaluates to true int y = (x == 10) ? 5 : 9; // y will equal 5 since the expression x == 10 evaluates to true
``` ```
False Condition: False Condition:
@ -53,8 +51,8 @@ Here is a program to illustrate the `instanceof` operator:
// As obj is of type person, it is not an // As obj is of type person, it is not an
// instance of Boy or interface // instance of Boy or interface
System.out.println("obj1 instanceof Person: " + (obj1 instanceof Person)); /*it returns true since obj1 is an instance of person */ System.out.println("obj1 instanceof Person: " + (obj1 instanceof Person)); /*it returns true since obj1 is an instance of person */
``` ```
# More Information
- [Java Operators](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html)
- [Summary of Operators](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html)