-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
77 lines (59 loc) · 2.14 KB
/
Main.java
File metadata and controls
77 lines (59 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.example;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
/**
*Ky eshte class Main
*/
public class Main {
final static int MAX_POINTS = 100;
public static void main(String[] args) {
String name = "Livio";
int age = 24;
int numToCheck = 10;
//Funksione qe nuk kthejn value (void)
printNameAge(name, age);
printVar();
//Printimi i values qe kthehen nga funksione/metoda
System.out.println("Shuma: "+printSum(1,3));
System.out.println("\nA eshte "+numToCheck +" positive apo negative:\n");
System.out.println(checkNum(numToCheck) ? "Positive": "Negative");
//Printimi i nje variable konstante final
System.out.println("\nMax points are: " + MAX_POINTS);
/*
Ndryshimi mes variable int dhe Integer:
* */
int a = 5;
String diff = "Integer eshte nje java class , int eshte primitiv.\n";
Integer b = 5;
System.out.println(diff +"\nVariable a: " + a +"\nVariable b: "+ b + "\nClass/Type of b: " + b.getClass());
}
//Funksioni per printim emer, mosha
public static void printNameAge(String name, int age) {
System.out.println("My name is:"+ name + " Age: " +age );
}
//Funksioni per printim variable te ndryshme te deklaruara
public static void printVar(){
String explanation = "\nVariable te ndryshme";
int num = 10;
double dNum = 10.0;
boolean bool = false;
char letter = 'A';
System.out.println(explanation);
System.out.println(num);
System.out.println(dNum);
System.out.println(bool);
System.out.println(letter);
}
//Funksion/Metode per shumen mes dy numrave
public static int printSum(int n1, int n2){
System.out.println("\nPrintimi i shumes mes "+n1+" dhe "+n2);
return n1 + n2;
}
//Funksion/Metode per te kontrolluar nese numri eshte pozitiv
public static boolean checkNum( int n){
if(n>0){
return true;
}
return false;
}
}