09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object...

68
Chapter 9 Ch 1 – Introduction to Computers and Java Objects and Classes 1

Transcript of 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object...

Page 1: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Chapter 9

Ch 1 – Introduction to Computers and Java

Objects and Classes

1

Page 2: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

ConstructorsFraction f = new Fraction();

Constructor

2

Page 3: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Use a constructor to initialize an object

▪A class may define as many constructors as needed

▪Java provides one default constructor if you do not explicitly define a constructor

▪A constructor has the same name as the class

3

Page 4: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Distance>

First let's look at the UML class Diagram for Distance.

Distance

- feetField: int- inchesField: double- labelField: String- set(int feet, double inches, String label): void

+ getFeet(): int+ setFeet(int feet): void+ getInches(): double+ setInches(double inches): void+ getLabel(): String

4

Constructors are usually not shown in the UML class diagram; they are assumed.

Page 5: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Distance.java>

public class Distance { private int feetField; private double inchesField; private String labelField;

// This setter gets called by all other methods to perform // initialization. It is our designated setter. private void set(int feet, double inches, String label) { if (feet < 0) { System.out.println("Error: Negative feet::set to 0"); } else { feetField = feet; }// end if if (inches < 0) { System.out.println("Error: Negative inches::set to 0"); } else { inchesField = inches; }// end if labelField = label; }// end setDistance()

5

The reason the method set is private has to do with subclassing or inheritance, which is covered later in the book. Although we do not cover inheritance in this course, we should still follow proper practices from the get go. At least that way your code is ready, right out of the box.

Page 6: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed < Distance.java >

public Distance() { this(0, 0.0, "na"); // call 3 argument constructor // set(0, 0.0, "na"); // or call set }// end Distance()

// Designated constructor. All others will call this one. public Distance(int feet, double inches, String label) { set(feet, inches, label); }// end Distance()

public Distance(int feet, double inches) { this(feet, inches, "na"); // set(feet, inches, "na");}// end Distance()

6

Having

Page 7: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed < Distance.java >

public int getFeet() { return feetField; }// end getFeet()

public void setFeet(int feet) { set(feet, inchesField, labelField); }// end setFeet()

7

Page 8: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed < Distance.java >

public double getInches() { return inchesField; }// end getInches()

public void setInches(double inches) { set(feetField, inches, labelField); } // end setInches()

8

Page 9: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed < Distance.java >

@Override public String toString() { return labelField + ": " + feetField + "'-" + String.format("%.1f\"", inchesField); }// end toString()}// end Distance

9

Page 10: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<DistanceDemo.java>

package distancedemo;

public class DistanceDemo {

public static void main(String[] args) { Distance d1 = new Distance(); Distance d2 = new Distance(10, 6.5); Distance d3 = new Distance(10, 3.0, "d3");

10

System.out.println(d1.toString()); System.out.println(d2.toString()); System.out.println(d3.toString()); System.out.println();

Constructors

Page 11: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<DistanceDemo.java>

11

Page 12: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<DistanceDemo.java>

d1.setDistance(20, -10.0, "d1"); System.out.println(d1.toString()); }// end main()}// end DistanceDemo

12

Page 13: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ Constructors have the same name as the class

▪ Java will provide a default constructor, if you do not provide any

▪ Constructors initialize the object

▪ All constructors should call the designated constructor

13

Page 14: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Brainteaser time!

Q::Given the class PointDemo, which is not a valid constructor?

14

(A)PointDemo()(B)PointDemo(int x, int y)(C)pointDemo(int x, int y)(D)None of the above

Page 15: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Static Variables and

Static Methods

15

static = shared

Page 16: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

main() Revisited

Let's examine main() more closely

16

Page 17: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

When your application is loaded, a call is made to the method main()

17

Page 18: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

main() is said to be the entry point of the application

18

Page 19: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Interestingly enough, the call is made without the use of an object

19

Page 20: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

The magic is in the static keyword

public static void main(String args[])

20

Page 21: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

static makes the method a class-level method

21

Page 22: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class-level or shared, means the method is called on the

class, not an object

22

Page 23: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Convert.java>

package convertdemo;

public class Convert { private static final double DEGREES_PER_RADIAN = 180.0 / Math.PI;

private static final double RADIANS_PER_DEGREE = Math.PI / 180.0;

23

public static double toDegrees(double radians) { return radians * DEGREES_PER_RADIAN; }// end toDegrees()

public static double toRadians(double degrees) { return degrees * RADIANS_PER_DEGREE; }// end toRadians()

Page 24: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Convert.java>

public static double toCelcius(double fahrenheit) { return (fahrenheit - 32.0) / 1.8; }// end toCelcius()

public static double toFahrenheit(double celcius) { return 1.8 * celcius + 32.0; }// end toFahrenheit()}// end Convert

24

Page 25: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<ConvertDemo.java>

package convertdemo;

public class ConvertDemo {

public static void main(String[] args) { // Convert 45 degrees to radians. System.out.printf("45 degrees are equivalent to %1$.3f radians\n", Convert.toRadians(45.0)); // Convert PI radians to degrees. System.out.printf("PI radians are equivalent to %1$.1f degrees\n", Convert.toDegrees(Math.PI));

25

Page 26: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<ConvertDemo.java>

// Convert 0 degrees C to F. System.out.printf("0 degrees C are equivalent to %1$.1f degrees F\n", Convert.toFahrenheit(0.0)); // Convert 212 degrees F to C. System.out.printf("212 degrees F are equivalent to %1$.1f degrees C\n", Convert.toCelcius(212.0)); }// end main()}// end ConvertDemo

26

Page 27: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Instance variables can also be shared by all objects

private static <type> <varName> =

<initValue>

27

Page 28: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Deck.java>

package deckdemo;

public class Deck { private static int cardsDealtSoFarField = 0; public static final int CARDS_IN_THE_DECK = 52; // Returns the number of cards dealt out so far. public static int cardsDealtCount() { return Deck.cardsDealtSoFarField; }// end cardsDealt()

28

Page 29: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Deck.java>

// Displays a message indicating a card has been dealt. public static void dealACard() { Deck.cardsDealtSoFarField += 1; if (Deck.cardsDealtCount() == 1) { System.out.println(Deck.cardsDealtCount() + " card was dealt."); } else { System.out.println(Deck.cardsDealtCount() + " cards were dealt."); }// end if

29

Page 30: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Class Deconstructed <Deck.java>

// Check if deck needs to be shuffled. if (Deck.cardsDealtCount() == CARDS_IN_THE_DECK) { Deck.shuffle(); }// end if }// end dealACard() // Shuffles the deck by resetting the cardsDealtSoFarField to 0. public static void shuffle() { System.out.println("... Shuffling the deck..."); Deck.cardsDealtSoFarField = 0; }// end shuffle()}// end Deck

30

Page 31: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<DeckDemo.java>

package deckdemo;

public class DeckDemo {

public static void main(String[] args) { // Deal 52 cards. System.out.println("Cards dealt so far: " + Deck.cardsDealtCount()); for (int card = 1; card <= Deck.CARDS_IN_THE_DECK; card++) { Deck.dealACard(); } // end for

31

Page 32: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<DeckDemo.java>

// Deal two more cards. Deck.dealACard(); Deck.dealACard(); // Reshuffle the deck and deal another card. Deck.shuffle(); Deck.dealACard(); }// end main()}// end DeckDemo

32

Page 33: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ static means shared by all objects (class-level)

▪ Instance methods require a receiving object

▪ static methods are called on the class, not a receiving object

▪ static methods cannot access instance level members (methods, variables) – no this passed

33

Page 34: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Writing Methods

34

public void ....

Page 35: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Writing methods 101

▪ Try to write one method at a time

▪ Test each method immediately after coding it

▪ Use a driver (main() basically) to test each method

▪ Follow a bottom-up or top-down approach

35

Page 36: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Bottom-up tests called methods first

36

public void outputSquared(int value) {

value = squareIt(value); System.out.println("Value squared: " + value);}

called methodprivate int squareIt(int value) { return value * value;}

implement this method fully and call it directly from your driver

caller method

this method will not be tested now; it doesn't even have to be implemented yet

Page 37: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Top-down tests caller first

37

public void outputSquared(int value) { value = squareIt(value); System.out.println("Value squared: " + value);}

caller method

private int squareIt(int value) { return 0;}

return any value that satisfies the compiler, since we are only testing the caller now

called method

here we only interested in testing the caller. If we getthe value (0) displayed or not

Page 38: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ Testing assures program is robust

▪ Test the caller first, by providing called stubs (syntactically proper only)

▪ Test the called first, by implementing fully and calling directly from driver

38

Page 39: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Brainteaser time!

Develop a Time class and use both testing techniques.

39

Time

- hourField: int - 24 hour universal format - minuteField: int

+ getHour(): int + setHour(int hour): void + getMinute(): int + setMinute(int minute): void + setTime(int hour, int minute): void + toString(): string+ toStringStandard(): string - 12 hour standard format

Page 40: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Overloading

40

METHOD LOADING

Page 41: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

A method can have many signatures

41

public Distance() {}

public Distance(int feet, double inches) {}

public Distance(int feet) {}

public Distance(double inches) {}

Page 42: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

A method's signature consists of its name and parameters

42

Page 43: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Overloading makes use of a method's signature

43

Page 44: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Overloaded methods have the same name

44

Page 45: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

but vary in type and number of parameters

45

Page 46: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Java searches for closest method match

46

public Distance() {}

public Distance(int feet, double inches) {}

public Distance(int feet) {}

public Distance(double inches) {}

Distance d1 = new Distance();

Distance d2 = new Distance(10, 3.5);

Distance d3 = new Distance(10);

Distance d4 = new Distance(3.5);

Page 47: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Note: the return type is not part of the signature

47

Page 48: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Given these two methods

int getValue() double getValue()

48

What does Java do now?

I said: "These are the same; returns don't

count"

Page 49: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ Methods can be overloaded

▪ Each method signature must be unique

▪ If methods differ only in their return type, Java will complain

49

Page 50: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Information Hiding

Revisited

50

Page 51: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Object variables are references

51

cpuField

ramField

pccpu object

ram object

pc object

Page 52: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

= only copies the reference

52

PC pc2 = pc1;

// Now, both pc1 and pc2 point to pc1's object

Page 53: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Objects can be changed from any reference

53

pc2.setRam = "2 GB";

// This changes pc1's ram object as well.// Both pc1 and pc2 refer to the same object after all.

Page 54: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Private object instance variablescan be changed also

54

Ram ram = pc1.getRam();ram.setRam("4 GB");

// Although ramField is private in PC, this exposes// it to changes.

// pc1's ram object is now "4 GB".

Page 55: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ Object variables as instance variables can cause subtle problems

▪ If you must protect instance objects, then return copies of them

▪ Trade off: Protection of object v. efficient memory use

55

Page 56: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Enumeration As A Class

56

enum LightState {...}

Page 57: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

enum is actually a class

57

enum LightState { OFF, ON, DIMMED, FLICKERING}

public static objects

LightState class

Page 58: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<EnumDemo.java>

package enumdemo;

public class EnumDemo { enum LightState { // Each object is initialized to a color. OFF("black"), ON("white"), DIMMED("gray"), FLICKERING("red"); private final String colorField; // Private constructor to set the color. private LightState(String color) { colorField = color; }// end LightState()

58

Page 59: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<EnumDemo.java>

// Public accessor to get color. public String getColor() { return colorField; }// end getColor() }// end LightState public static void main(String[] args) { LightState off = LightState.OFF; LightState on = LightState.ON; LightState dimmed = LightState.DIMMED; LightState flickering = LightState.FLICKERING;

59

Page 60: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Application Deconstructed<EnumDemo.java>

System.out.println("State:" + off.toString() + " :: Color:" + off.getColor()); System.out.println("State:" + on.toString() + " :: Color:" + on.getColor()); System.out.println("State:" + dimmed.toString() + " :: Color:" + dimmed.getColor()); System.out.println("State:" + flickering.toString() + " :: Color:" + flickering.getColor()); }// end main()}// end EnumDemo

60

Page 61: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ An enum is actually a Java class

▪ You can use several methods to obtain enum functionality

▪ You can enhance the enum class with instance variables and methods

61

Page 62: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Packages

62

Page 63: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

A package groups related classes together in a folder

63

Page 64: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

The folder has the same name as the package

64

Page 65: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Each class within the package is in its own <className>.java file

65

Page 66: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Each class imports a class or all classes from the package

66

Page 67: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

NetBeans specific: The name of package is under the src folder

67

package enumdemo

Page 68: 09.Objects and Classes - SIUEstornar/courses/notes/cs140/09.Objects... · 2015-01-12 · Object variables as instance variables can cause subtle problems ... An enum is actually a

Recap

▪ A package groups related classes in a folder

▪ The folder has the same name as the package

▪ Import the class you want from the package it is in

▪ Packages organize your classes logically

68