Skip to content

Commit a9f5905

Browse files
Updates
1 parent a6233b7 commit a9f5905

File tree

8 files changed

+117
-7
lines changed

8 files changed

+117
-7
lines changed

Car.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class Car {
2+
String make = "Ford";
3+
String model = "Mustang";
4+
int year = 2020;
5+
String color = "black";
6+
double price = 50000.00;
7+
8+
void drive(){
9+
System.out.println("You drive the car");
10+
}
11+
void brake(){
12+
System.out.println("You step on the brakes");
13+
}
14+
15+
}

Final.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
public class Final{
3+
public static void main(String[] args){
4+
final double PI = 3.14159;
5+
System.out.println(PI);
6+
return;
7+
}
8+
}

Human.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class Human {
2+
String name;
3+
int age;
4+
double weight;
5+
Human(String name, int age, double weight){
6+
this.name = name;
7+
this.age = age;
8+
this.weight = weight;
9+
}
10+
11+
void eat(){
12+
System.out.println(this.name + " eating");
13+
}
14+
15+
void drink(){
16+
System.out.println(this.name + " drinking");
17+
}
18+
}

Main.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
public class Main{
22
public static void main(String[] args){
3-
String name = "Bro";
4-
hello(name);
5-
return;
6-
}
7-
8-
static void hello(String name){
9-
System.out.println("hello " + name);
3+
Human human = new Human("Ranuga", 15, 50.0);
4+
Human human2 = new Human("Disansa", 15, 50.0);
105
return;
116
}
127
}

Methods.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class Methods{
2+
public static void main(String[] args){
3+
int x = 3;
4+
int y = 4;
5+
return;
6+
}
7+
8+
static int add(int num1, int num2){
9+
return num1 + num2;
10+
}
11+
// public static void main(String[] args){
12+
// String name = "Bro";
13+
// int age = 21;
14+
// hello(name, age);
15+
// return;
16+
// }
17+
//
18+
// static void hello(String name, int age){
19+
// System.out.println("hello " + name + age);
20+
// return;
21+
// }
22+
}

OOP.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class OOP{
2+
public static void main(String[] args){
3+
Car myCar = new Car();
4+
Car myCar2 = new Car();
5+
6+
System.out.println(myCar.model);
7+
System.out.println(myCar.make);
8+
9+
myCar.drive();
10+
myCar.brake();
11+
return;
12+
}
13+
}

OverLoading.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class OverLoading{
2+
public static void main(String[] args){
3+
return;
4+
}
5+
6+
static int add(int a, int b){
7+
return a + b;
8+
}
9+
10+
static int add(int a, int b, int c){
11+
return a+b+c;
12+
}
13+
}

PrintF.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
public class PrintF{
3+
public static void main(String[] args){
4+
// System.out.printf("This is a format string %d", 123);
5+
boolean myBoolean = true;
6+
char myChar = '@';
7+
String myString = "Bro";
8+
int myInt = 50;
9+
double myDouble = 1000;
10+
11+
System.out.printf("%b", myBoolean);
12+
System.out.printf("%c", myChar);
13+
System.out.printf("%s", myString);
14+
System.out.printf("%d", myInt);
15+
System.out.printf("%f", myDouble);
16+
17+
System.out.printf("Hello %10s", myString);
18+
System.out.printf("Hello %-10s", myString);
19+
20+
System.out.printf("%.2f", myDouble);
21+
22+
23+
return;
24+
}
25+
}
26+

0 commit comments

Comments
 (0)