-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
22 lines (19 loc) · 955 Bytes
/
Main.java
File metadata and controls
22 lines (19 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package OverloadedConstructors;
public class Main {
public static void main(String[] args) {
// overloaded constructors = multiple constructors within a class with the same name, but have different
// parameters. name + parameters = signature
Pizza pizza = new Pizza("Thicc crust", "tomato", "mozzarella", "pepperoni");
System.out.println("Here are the ingredients of your pizza: ");
System.out.println(pizza.bread);
System.out.println(pizza.sauce);
System.out.println(pizza.cheese);
System.out.println(pizza.topping);
Pizza cheesePizza = new Pizza("Thicc crust", "tomato", "mozzarella");
System.out.println("Here are the ingredients of your pizza: ");
System.out.println(cheesePizza.bread);
System.out.println(cheesePizza.sauce);
System.out.println(cheesePizza.cheese);
System.out.println(cheesePizza.topping); // returns null
}
}