Skip to content

Commit 2716357

Browse files
committed
Initial commit - Java tutorials
0 parents  commit 2716357

29 files changed

+810
-0
lines changed

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
### IntelliJ IDEA ###
2+
out/
3+
!**/src/main/**/out/
4+
!**/src/test/**/out/
5+
.kotlin
6+
7+
### Eclipse ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
bin/
16+
!**/src/main/**/bin/
17+
!**/src/test/**/bin/
18+
19+
### NetBeans ###
20+
/nbproject/private/
21+
/nbbuild/
22+
/dist/
23+
/nbdist/
24+
/.nb-gradle/
25+
26+
### VS Code ###
27+
.vscode/
28+
29+
### Mac OS ###
30+
.DS_Store

.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Prime Program.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

src/Hello.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
// In a file, there can be multiple classes but there will be just one public class
3+
4+
public class Hello { // this is a block
5+
6+
public static void main (String[] args) {
7+
System.out.println("Hello World!");
8+
System.out.println(4 + 3);
9+
System.out.println();
10+
}
11+
}

src/Variables.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
public class Variables {
2+
public static void main(String[] args) {
3+
4+
boolean isPassed = true;
5+
long count = 12;
6+
int countInt = (int)count;
7+
8+
byte marks = 13;
9+
short studentsCount = 1235;
10+
11+
float pi = 3.14f;
12+
13+
double secondPi = 3.143213241123; // will print all precision
14+
15+
float x = 3.143213241123f; // will print till 7 decimal points
16+
17+
System.out.println(pi);
18+
System.out.println(secondPi);
19+
System.out.println(x);
20+
21+
char myLetter = 'a';
22+
System.out.println(myLetter);
23+
24+
int age = 128;
25+
byte newAge = (byte)age; // explicit typecasting, lossy conversion
26+
27+
System.out.println(newAge); // -128 -> rotation
28+
}
29+
}

src/animals/Animal.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package animals;
2+
3+
public class Animal {
4+
5+
// protected constructor
6+
protected Animal() {
7+
System.out.println("Animal constructor");
8+
}
9+
10+
// protected method
11+
protected void eat () {
12+
System.out.println("Animal is eating");
13+
}
14+
}

src/arrays/BasicsOfArray.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package arrays;
2+
3+
public class BasicsOfArray {
4+
public static void main(String[] args) {
5+
// int age[]; // declaration
6+
// age = new int[5]; // allocation
7+
8+
// int age[] = new int[5];
9+
//
10+
// age[0] = 5;
11+
// age[1] = 2;
12+
//
13+
// System.out.println(age[0]);
14+
// System.out.println(age[1]);
15+
// System.out.println(age[2]);
16+
//
17+
// System.out.println(age.length);
18+
19+
20+
// int marks[] = {98, 12, 45, 12, 65};
21+
//
22+
// System.out.println(marks[0]);
23+
24+
25+
String names[] = {"Rahul", "Prateek", "Mayank", "Ravi"};
26+
27+
for(int i = 0; i < names.length; i++) {
28+
System.out.println("Name is " + names[i]);
29+
}
30+
31+
for (String name: names) {
32+
System.out.println("for each " + name);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)