-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainOverloading.java
More file actions
37 lines (32 loc) · 839 Bytes
/
mainOverloading.java
File metadata and controls
37 lines (32 loc) · 839 Bytes
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
import java.util.*;
class item {
int code;
String name;
float price;
void giveData(int code,String name, float price)
{
this.code = code;
this.name = name;
this.price = price;
}
void giveData(float price)
{
this.price = price;
}
void displayData()
{
System.out.println("The code is " + code);
System.out.println("The name is " + name);
System.out.println("The price is " + price);
}
}
class Overloading {
public static void main(String[] args) {
item i = new item();
i.giveData(10,"nut",2000);
i.displayData();
i.giveData(2500);
System.out.println("After modification");
i.displayData();
}
}