-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpeintNumber_method_overloading.java
More file actions
41 lines (37 loc) · 1.11 KB
/
peintNumber_method_overloading.java
File metadata and controls
41 lines (37 loc) · 1.11 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
import java.util.Scanner;
public class printNumber {
public static int printN(int n) {
return n;
}
public static byte printN(byte n) {
return n;
}
public static short printN(short n) {
return n;
}
public static long printN(long n) {
return n;
}
public static float printN(float a) {
return a;
}
public static double printN(double c) {
return c;
}
public static void main(String[] args) {
System.out.println("Enter byte value-");
Scanner sc = new Scanner(System.in);
byte b = sc.nextByte();
System.out.println("Byte value - " + printN(b));
short s = sc.nextShort();
System.out.println("Short value - " + printN(s));
long l = sc.nextLong();
System.out.println("Long value - " + printN(l));
int i = sc.nextInt();
System.out.println("Int value - " + printN(i));
float f = sc.nextFloat();
System.out.println("Float value - " + printN(f));
double d = sc.nextDouble();
System.out.println("Double value - " + printN(d));
}
}