Skip to content

Update java.md #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions c.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ Switch is an alternative to if-else-if ladder.
```c
switch(conditional-expression) {
case value1:
// code
break; // optional
// code
break; // optional
case value2:
// code
break; // optional
// code
break; // optional
...

default:
// code to be executed when all the above cases are not matched;
// code to be executed when all the above cases are not matched;
}
```
### 3. For:
Expand Down
4 changes: 2 additions & 2 deletions cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ Switch is an alternative to If-Else-If ladder.
```c
switch(conditional-expression){
case value1:
// code
// code
break; // optional
case value2:
// code
// code
break; // optional
......

Expand Down
6 changes: 3 additions & 3 deletions csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ Switch is an alternative to If-Else-If ladder.
```c#
switch(conditional-expression) {
case value1:
// code
// code
break; // optional
case value2:
// code
// code
break; // optional
...

default:
// code to be executed when all the above cases are not matched;
// code to be executed when all the above cases are not matched;
}
```
### 3. For:
Expand Down
4 changes: 2 additions & 2 deletions go.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ Switch is an alternative to If-Else-If ladder.
```go
switch conditional-expression {
case value1:
// code
// code
break; // optional
case value2:
// code
// code
break; // optional
...

Expand Down
6 changes: 3 additions & 3 deletions groovy.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ Switch is an alternative to If-Else-If ladder and to select one among many block
```java
switch(conditional-expression) {
case value1:
// code
// code
break; // optional
case value2:
// code
// code
break; // optional
...

default:
//code to be executed when all the above cases are not matched;
//code to be executed when all the above cases are not matched;
}
```

Expand Down
14 changes: 7 additions & 7 deletions java.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Java is a very popular general-purpose programming language, it is class-based a
## Variables

```java
short x = 999; // -32768 to 32767
int x = 99999; // -2147483648 to 2147483647
long x = 99999999999L; // -9223372036854775808 to 9223372036854775807
short x = 999; // -32768 to 32767
int x = 99999; // -2147483648 to 2147483647
long x = 99999999999L; // -9223372036854775808 to 9223372036854775807

float x = 1.2;
double x = 99.99d;

byte x = 99; // -128 to 127
byte x = 99; // -128 to 127
char x = 'A';
boolean x = true;
```
Expand Down Expand Up @@ -134,9 +134,9 @@ Class is the blueprint of an object, which is also referred as user-defined data

```java
class Mobile {
public: // access specifier which specifies that accessibility of class members
string name; // string variable (attribute)
int price; // int variable (attribute)
public: // access specifier which specifies that accessibility of class members
string name; // string variable (attribute)
int price; // int variable (attribute)
};
```
### How to create a Object:
Expand Down
6 changes: 3 additions & 3 deletions javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ const users = [
```
## Functions
```javascript
function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
console.log(`Hello ${name}!`);
}

greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar
```
## Loops
### 1. If:
Expand Down
4 changes: 2 additions & 2 deletions perl.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ There is no need to specify the type of the data in Perl as it is loosely typed
In Perl, there is no need to explicitly declare variables to reserve memory space. When you assign a value to a variable, declaration happens automatically.

```perl
$var-name =value; #scalar-variable
@arr-name = (values); #Array-variables
$var-name =value; #scalar-variable
@arr-name = (values); #Array-variables
%hashes = (key-value pairs); # Hash-variables
```
## Loops
Expand Down
10 changes: 5 additions & 5 deletions php.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ Switch is used to execute one set of statement from multiple conditions.
```php
switch(conditional-expression) {
case value1:
// code if the above value is matched
break; // optional
// code if the above value is matched
break; // optional
case value2:
// code if the above value is matched
// code if the above value is matched
break; // optional
...

default:
// code to be executed when all the above cases are not matched;
// code to be executed when all the above cases are not matched;
}

```
Expand All @@ -106,7 +106,7 @@ for(Initialization; Condition; Increment/decrement){
```
#### For-each:
```php
// you can use any of the below syntax
// you can use any of the below syntax
foreach ($array as $element-value) {
//code
}
Expand Down
6 changes: 3 additions & 3 deletions typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ for(Initialization; Condition; Increment/decrement){

let arr = [1, 2, 3, 4, 5];
for (let ele of arr) {
// code
// code
}

for (let index in arr) {
Expand Down Expand Up @@ -149,5 +149,5 @@ function Addition(a: any, b:any): any {
return a + b;
}
Addition("Hello ","foo"); // outputs Hello foo
Addition(2,3); //outpus 5
```
Addition(2,3); //outpus 5
```
8 changes: 4 additions & 4 deletions vb.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OneCompiler's VB.net online editor supports stdin and users can give inputs to p
Public Module Program
Public Sub Main(args() As string)
Dim name as String = Console.ReadLine() ' Reading input from STDIN
Console.WriteLine("Hello " & name) ' Writing output to STDOUT
Console.WriteLine("Hello " & name) ' Writing output to STDOUT
End Sub
End Module
```
Expand Down Expand Up @@ -57,15 +57,15 @@ End If
If(conditional-expression)Then
'code if the conditional-expression is true
Else
'code if the conditional-expression is false
'code if the conditional-expression is false
End If
```

### 3. If-else-if ladder

```vb
If(conditional-expression)Then
'code if the above conditional-expression is true
'code if the above conditional-expression is true
Else If(conditional-expression) Then
'code if the above conditional-expression is true
Else
Expand All @@ -77,7 +77,7 @@ End If

```vb
If(conditional-expression)Then
'code if the above conditional-expression is true
'code if the above conditional-expression is true
If(conditional-expression)Then
'code if the above conditional-expression is true
End If
Expand Down