first commit

This commit is contained in:
LinlyBoi
2021-11-06 23:35:03 +02:00
commit 63ba32bb3c
27 changed files with 498 additions and 0 deletions

32
Methods.java Normal file
View File

@@ -0,0 +1,32 @@
class Scratch {
public static void main(String[] args) {
// methods..functions but associated with objects?
int x = 3;
int y = 4;
int z = 5;
int result = sum(x,y); //both result(s) are local variables :D
System.out.println(result);
}
static int sum(int a,int b)
{
int result = a + b;
System.out.println("This adds only 2 values!");
return result; // return x+y; works too
}
//time to overload it!
static int sum(int a,int b,int c)
{
System.out.println("This adds THREE values!");
return a + b + c;
}
/* same method name but different signature
* Signatures are method name + method parameters(Number,Data type etc) */
}