Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bd255c0

Browse files
addded upto methods
1 parent f1f5dcf commit bd255c0

File tree

19 files changed

+288
-24
lines changed

19 files changed

+288
-24
lines changed

‎Java Language/Array/Arrayjava.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package Array;
2+
public class Arrayjava {
3+
4+
public static void main(String[] args) {
5+
6+
String[] cars = { "Volvo", "BMW", "Ford", "Mazda" };
7+
int[] myNum = { 10, 20, 30, 40 };
8+
9+
System.out.println(cars[2]);
10+
cars[0] = "Opel"; // This will change the array value.
11+
System.out.println(cars[0]);
12+
13+
System.out.println(myNum[2]);
14+
15+
16+
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package Array;
2+
public class LoopsThroughAnArray {
3+
public static void main(String[] args) {
4+
5+
String[] count = {"one", "two", "three", "four", "five"};
6+
for(int i = 0; i < count.length; i++){
7+
System.out.println(count[i]);
8+
9+
}
10+
11+
for (String show : count) {
12+
System.out.println(show);
13+
14+
}
15+
}
16+
17+
}

‎Java Language/Array/PracticeArray.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class PracticeArray{
2+
public static void main(String[] args) {
3+
// int[] arr = {1, 3, 4, 6, 7, 8 ,9 };
4+
// for (int i = 0; i < arr.length; i++) {
5+
// System.out.println(arr[i]);
6+
// }
7+
// System.out.println("the length of the array is : " + arr.length);
8+
9+
10+
// 2D Array
11+
int[][] arr = {
12+
{1,2,3,4},
13+
{5,6,7,8},
14+
{9,10,11,12},
15+
{13,14,15,16}
16+
};
17+
18+
for (int i = 0; i < arr.length; i++) {
19+
for (int j = 0; j < arr[i].length; j++) {
20+
System.out.print(" " + arr[i][j]);
21+
}
22+
23+
}
24+
System.out.println(" Element is : " + arr[2][0]);
25+
}
26+
}

‎Java Language/Array/twoDarray.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package Array;
2+
public class twoDarray {
3+
public static void main(String[] args) {
4+
5+
// index 0 1 2
6+
int[][] arr = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 } };
7+
// index 0 1 2 3 0 1 2 3 0 1 2 3
8+
9+
int num = arr[2][2];
10+
System.out.println(num);
11+
12+
int[][] myNumbers = { { 1, 2, 3, 4 }, { 5, 6, 7 } };
13+
for (int i = 0; i < myNumbers.length; i++) {
14+
for (int j = 0; j < myNumbers[i].length; j++) {
15+
System.out.println(myNumbers[i][j]);
16+
}
17+
}
18+
19+
}
20+
21+
}
22+
23+
// 0 1 2 3
24+
// 4 5 6 7
25+
// 8 9 10 11

‎Java Language/Helloworld.java renamed to ‎Java Language/BasicJAVA/Helloworld.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Basic;
12
public class Helloworld{
23
public static void main(String[] args){
34
System.out.println("Hello World");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package Basic;
2+
0 1 2 3
3+
// 4 5 6 7
4+
// 8 9 10 11

‎Java Language/variables.java renamed to ‎Java Language/BasicJAVA/variables.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package Basic;
12
public class variables {
23
public static void main(String[] args) {
34

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package FORloop;
2+
public class continueANDbreak {
3+
public static void main(String[] args) {
4+
5+
int i = 0;
6+
while (i < 10) {
7+
System.out.println(i);
8+
i++;
9+
if (i == 4) {
10+
break;
11+
}
12+
}
13+
14+
int j = 0;
15+
while (j < 10) {
16+
if (j == 4) {
17+
j++;
18+
continue;
19+
}
20+
System.out.println(j);
21+
j++;
22+
}
23+
}
24+
25+
}

‎Java Language/FORloop/forLoop.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package FORloop;
2+
public class forLoop {
3+
4+
public static void main(String[] args) {
5+
// for (int i = 0; i < 5; i++) {
6+
// System.out.println(i);
7+
// }
8+
for (int e = 0; e <= 10; e = e + 2) {
9+
System.out.println(e);
10+
}
11+
12+
// for each loop
13+
14+
// for (type variableName : arrayName) {
15+
// code block to be executed
16+
// }
17+
18+
String[] count = { "one", "two", "three", "four", "five"};
19+
for (String a : count) {
20+
System.out.println(a);
21+
22+
}
23+
24+
// break; and continue;
25+
for (int i = 0; i < 10; i++) {
26+
if (i == 4) {
27+
continue;
28+
}
29+
System.out.println(i);
30+
}
31+
32+
33+
for (int g = 0; g < 10; g++) {
34+
if (g == 4) {
35+
break;
36+
}
37+
System.out.println(g);
38+
}
39+
40+
41+
42+
}
43+
}

‎Java Language/IFelse/if_else.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package IFelse;
2+
public class if_else{
3+
public static void main(String[] args) {
4+
// int a = 4, b = 3;
5+
// if (a<b) {
6+
// System.out.println("b is grater than a");
7+
8+
// }
9+
// else{
10+
// System.out.println("a is grater than b");
11+
// }
12+
int num = 3;
13+
// if (num >5) {
14+
// System.out.println("Good Morning");
15+
16+
// }
17+
// else if (num<5) {
18+
// System.out.println("Good Afternoon");
19+
20+
// }
21+
// else{
22+
// System.out.println("Good Night");
23+
// }
24+
25+
26+
String str = (num>5) ? "Good Morning" :"Good Night" ;
27+
System.out.println(str);
28+
}
29+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /