From 95cd443efc13c9c6fdd4405500644984a416c5f8 Mon Sep 17 00:00:00 2001 From: David Schmidt Date: Fri, 18 Jan 2019 04:49:59 +0100 Subject: [PATCH] improve guide/english/java/basic-operations (#33891) added links, fixed indention --- guide/english/java/basic-operations/index.md | 30 +++++++++----------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/guide/english/java/basic-operations/index.md b/guide/english/java/basic-operations/index.md index 8d586e49cf..974a0f9b66 100644 --- a/guide/english/java/basic-operations/index.md +++ b/guide/english/java/basic-operations/index.md @@ -18,8 +18,7 @@ Java supports the following operations on variables: * __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 ** -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;` The Assignment operators (`+=`, `-=`, `*=`, `/=`, `%=`, `<<=`, `>>=`, `&=`, `^=`, `|=`) are just a short form which can be extended. @@ -30,16 +29,15 @@ Example: True Condition: ```java - int x = 10; - int y = (x == 10) ? 5 : 9; // y will equal 5 since the expression x == 10 evaluates to true - +int x = 10; +int y = (x == 10) ? 5 : 9; // y will equal 5 since the expression x == 10 evaluates to true ``` False Condition: ```java - int x = 25; - int y = (x == 10) ? 5 : 9; // y will equal 9 since the expression x == 10 evaluates to false +int x = 25; +int y = (x == 10) ? 5 : 9; // y will equal 9 since the expression x == 10 evaluates to false ``` The `instanceof` operator is used for type checking. It can be used to test if an object is an instance of a class, a subclass or an interface. General format- @@ -47,14 +45,14 @@ The `instanceof` operator is used for type checking. It can be used to test if a Here is a program to illustrate the `instanceof` operator: ```Java - Person obj1 = new Person(); - Person obj2 = new Boy(); - - // As obj is of type person, it is not an - // instance of Boy or interface - System.out.println("obj1 instanceof Person: " + (obj1 instanceof Person)); /*it returns true since obj1 is an instance of person */ - - - ``` +Person obj1 = new Person(); +Person obj2 = new Boy(); +// As obj is of type person, it is not an +// instance of Boy or interface +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)