Download presentation
Presentation is loading. Please wait.
1
Chapter 8 INTERFACE AND PACKAGE
Java Programming Chapter 8 INTERFACE AND PACKAGE
2
Agenda 8.1 Basics of Interface 8.2 Multiple Interfaces
8.3 Multiple Inheritance Using Interface 8.4 Multilevel Interface 8.5 Packages 8.6 Create and Access Packages in Netbeans Ide 8.7 Static Import and Package Class 8.8 Access Specifiers
3
Introduction An interface is used to solve the problem of multiple inheritance by declaring the abstract methods in the interface and implementing these methods in the inherited classes. A package is used to group the classes and interfaces. Common functionality of classes is grouped together in one package and it accesses the package classes in another packages. To inherit a class from another class, restriction is provided on accessibility of the classes. This can be achieved by using various types of modifiers.
4
8.1 Basics of Interface An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. Interfaces are used to declare methods and variables without the implementation of the methods’ behaviors. The class makes use of the interface by implementing the methods of the interface. The features of interfaces are Interface cannot be instantiated An interface does not contain any constructors. All the methods in an interface are abstract.
5
Relationship between Classes and Interface
An interface is similar to a class, but there are important differences. Methods are declared in an interface. Implementation of the method should not be provided by an interface. The methods in an interface should always public. The variables in an interface should be constant. The constant variables are inherited by the class which implements this interface.
6
Relationship between Classes and Interface (Contd.)
The behavior of the method is defined in the class which implements the interface. Different classes may provide different implementation codes for the methods declared in the interface. The method’s return type should be public and the variables declaration should be constant. The general structure of an interface is as follows: interface interface_name { final Variable1=value; public return-type methodname(parameter-list); }
7
Relationship between Classes and Interface (Contd.)
The class which implements the behavior of the interface should have the following syntax: class class_name implements interface_name { public return-type methodname(parameter-list) ... } The implements keyword is used to implement the interface methods in the inherited class. The interface method’s behavior is defined inside the inherited class. Program 8.1 shows how the interface is created and how the inherited class implements the interface. The program calculates the temperature in Fahrenheit and Celsius.
8
Program 8.1 illustrates the interface concept
//Calculating Temperature in Fahrenheit and celsius interface Temperaturemethods { //Method Declaration public double FahrenheitToCelsius(double degree); public double CelsiusToFahrenheit(double degree); } //inheriting class implements the interface class TemperatureDefinition implements Temperaturemethods double degree; //interface method Definition or implementation public double FahrenheitToCelsius(double degree) { return (degree - 32 * 5 / 9); //interface method Definition or implementation public double CelsiusToFahrenheit(double degree) { return (degree * 9 / ); } } public class Temperature { public static void main(String args[]) TemperatureDefinition t = new TemperatureDefinition(); t.degree = 54; System.out.println(“FahrenheitToCelsius:”+ t.FahrenheitToCelsius(t.degree)); System.out.println(“CelsiusToFahrenheit:”+ t.CelsiusToFahrenheit(t.degree)); Output 8.1 Fahrenheit To Celsius:37.0 Celsius To Fahrenheit:129.2
9
8.2 Multiple Interfaces Multiple inheritance cannot be achieved by class inheritance. Instead, multiple inheritance can be realized through implementing multiple interfaces. Multiple interfaces can be implemented by the inherited class by using comma separation for each interface. If one class needs to implement more than one interface, then the following syntax shows how multiple interfaces are implemented in the class. interface A { … } interface B { … } class Sample implements A,B
10
Program 8.2 shows multiple interfaces and the implementation of methods
//multiple interfaces AnnualHumidity and Temperature interface AnnualHumidity { //interface variables final double avghumidity_chennai=70; final double avghumidity_bengaluru=65; final double avghumidity_Hyderabad=56; final double avghumidity_thiruvananthapuram=78; } interface Temperature { //interface method declaration public double FahrenheitToCelsius(double degree); public double CelsiusToFahrenheit(double degree); class WeatherDetails implements AnnualHumidity,Temperature { double degree; //interface methods implementation public double FahrenheitToCelsius(double degree) { return (degree - 32 * 5 / 9); } public double CelsiusToFahrenheit(double degree) { return (degree * 9 / );
11
Program 8.2 (Contd.) Output 8.2 Humidity level in Chennai:70.0
public void print_humidity() { //interface final variables access System.out.println(“Humidity level in Chennai:”+avghumidity_chennai); Bengaluru:”+avghumidity_bengaluru); Hyderabad:”+avghumidity_Hyderabad); System.out.println(“Humidity level in Trivandrum:”+avghumidity_ thiruvananthapuram); } public class MultipleinterfaceExample { public static void main(String[] args) WeatherDetails w=new WeatherDetails(); w.degree=54; w.print_humidity(); System.out.println(“Fahrenheit To Celsius:”+w.FahrenheitToCelsius(w. degree)); System.out.println(“Celsius To Fahrenheit:”+w.CelsiusToFahrenheit(w. } Output 8.2 Humidity level in Chennai:70.0 Humidity level in Bengaluru:65.0 Humidity level in Hyderabad:56.0 Humidity level in Trivandrum:78.0 Fahrenheit To Celsius:37.0 Celsius To Fahrenheit:129.2
12
8.3 Multiple Inheritance Using Interface
Multiple inheritance is defined as two or more base classes being inherited by a single subclass. In Java this cannot be done for the reason that it may lead to ambiguous (uncertain) results. This means that if two base classes contain the same method name and signature but the definition is different, then when the subclass inherits two of the base classes, there may be a conflict regarding which base class method is invoked. This type of inheritance is not achieved directly in Java. Instead, it is achieved via interfaces in three ways. A class implements multiple interfaces. An interface extends multiple interfaces. A class extends another class and implements an interface.
13
Multiple Inheritance Using Interface (Contd.)
Figure 8.1 depicts the first and second type of multiple inheritance. The diagram shows that the first type of multiple interfaces are inherited by the class using implements keyword and this has been demonstrated in Program 8.2. The second type is where multiple interfaces are inherited by another interface using extends keyword as in class inheritance.
14
Program 8.3 //multiple inheritance interface Exam { public void display(); } class Student String name; int roll_no,mark1,mark2; Student(String n, int r, int m1, int m2) name=n; roll_no=r; mark1=m1; mark2=m2; void display() { System.out.println (“Name of Student: “+name); System.out.println (“Roll No. of Student: “+roll_no); System.out.println (“Marks of Subject 1: “+mark1); System.out.println (“Marks of Subject 2: “+mark2); } In the third type of multiple inheritance, a class has to extend one class and implement an interface which has following general structure. class A { .. } interface B class Sample extends A implements B The structure illustrates that a class sample can extend the class A, as well as implement an interface B. Program 8.3 illustrates the third type of multiple inheritance.
15
Program 8.3 (Contd.) Output 8.3 Name of Student: Ram
class Result extends Student implements Exam { Result(String n, int r, int m1, int m2) super(n,r,m1,m2); } public void display() super.display(); int total=(mark1+mark2); float percent=total*100/200; System.out.println (“Percentage: “+percent+”%”); public class Multipleinheritance { public static void main(String args[]) Result R = new Result(“Ram”,12,93,84); R.display(); } Output 8.3 Name of Student: Ram Roll No. of Student: 12 Marks of Subject 1: 93 Marks of Subject 2: 84 Percentage: 88.0%
16
8.4 Multilevel Interface interface name1 { ……………… } interface name2 extends name1 …………….. interface name3 extends name2 ……………. One interface being inherited by other interfaces is known as interface inheritance. A class can be directly inherited from the superclass using the keyword extends. In the same way, one interface can be inherited by another interface using the same extends keyword. As in multilevel inheritance, multilevel interface can be defined and implemented by the inherited class. The following is the general form of interface inheritance.
17
Program 8.4 illustrates interface inheritance.
//interface inheritance interface AnnualHumidity { //interface variables final double avghumidity_chennai=70; final double avghumidity_bengaluru=65; final double avghumidity_Hyderabad=56; final double avghumidity_thiruvananthapuram=78; } interface Temperature extends AnnualHumidity //interface method declaration public double FahrenheitToCelsius(double degree); public double CelsiusToFahrenheit(double degree); class WeatherDetails implements Temperature { double degree; public double FahrenheitToCelsius(double degree) { return (degree - 32 * 5 / 9); } public double CelsiusToFahrenheit(double degree) { return (degree * 9 / ); public void print_humidity() System.out.println(“Humidity level in Chennai:”+avghumidity_chennai); System.out.println(“Humidity level in Bengaluru:”+avghumidity_bengaluru); System.out.println(“Humidity level in Hyderabad:”+avghumidity_Hyderabad); System.out.println(“Humidity level in Trivandrum:”+avghumidity_ thiruvananthapuram); } }
18
Program 8.4 (Contd.) Output 8.4 Humidity level in Chennai:70.0
public class MultipleinterfaceExample { public static void main(String[] args) WeatherDetails w=new WeatherDetails(); w.degree=54; w.print_humidity(); System.out.println(“Fahrenheit To Celsius:”+w.FahrenheitToCelsius(w. degree)); System.out.println(“Celsius ToFahrenheit:”+w.CelsiusToFahrenheit(w.degree)); } Output 8.4 Humidity level in Chennai:70.0 Humidity level in Bengaluru:65.0 Humidity level in Hyderabad:56.0 Humidity level in Thiruvananthapuram:78.0 Fahrenheit To Celsius:37.0 Celsius To Fahrenheit:129.2
19
Table 8.1: Difference between abstract class and interface
Abstract class can have both abstract and non-abstract methods. Abstract class does not support multiple inheritance Abstract class can have final, non-final, static and nonstatic variables. Abstract class can have static methods, main method and constructor. Abstract class can provide the implementation of an interface. The abstract keyword is used to declare abstract class. Example: public abstract class Shape{ public abstract void draw(); } Interface Interface can have only abstract methods. Interface supports multiple inheritance. Interface has only static and final variables. Interface cannot have static methods, main method or constructor. Interface cannot provide the implementation of an abstract class. The interface keyword is used to declare interface. Example: public interface Drawable{ void draw(); }
20
8.5 Packages A major feature of OOP is the ability to reuse the code which has already been created. One way of achieving this is by extending the classes and implementing the interfaces. That is, inheritance and interfaces, which have been already discussed. These two ways of reusing the code is limited to the program. If there is a need to repeatedly use classes from other programs without copying the code into the programs, then reusing the code from other package classes can be accomplished by packages. A Java package is a group of related types of classes, interfaces and subpackages.
21
Benefits of a Java Package
Java package is used to categorize the classes and interfaces so that they can be easily maintained. Java package provides access protection. Java package removes naming collisions. The classes in the packages of other programs can be easily accessed. If two classes are in two different packages, they can have the same name; they may be referred by their fully qualified name, comprising the package name and class name. Packages provide a way to hide classes, thus preventing other programs or packages from accessing classes that are meant for internal use only. Packages are also used to separate the design from coding. First, design classes and their relationships are defined; then this will implement the code needed for the methods, without affecting the design.
22
Benefits of a Java Package (Contd.)
The Java Package can be divided into two types, built-in package and user-defined package. There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc. For instance, consider import java.lang.*; In the above statement, java is the base or core package and lang is a subpackage. The * symbol denotes the built-in classes, methods and data members available within the subpackage of lang. Figure 8.2 illustrates the hierarchy of pre-defined packages and their subpackages.
23
User-Defined Package The types of classes are created using inheritance, interface, polymorphism and abstract class. Using the concept of packages, these classes can be grouped together by categories for ease of access and uncertainties are avoided. Creating the user-defined java package comprises two steps as follows. 8.5.1 Creating Packages 8.5.2 Accessing a Package from Another Package
24
Subpackage package package_name1.package_name2;
Java also supports the concept of package hierarchy. This is done by specifying multiple names in a package statement, separated by dots. For example, package package_name1.package_name2; This approach is used to group related classes into a package and group the related packages into a larger package. Thus, the package inside a package is called a subpackage. It should be created to categorize the package further. Let us take an example. Sun Microsystem has defined a package named java that contains many classes like System, String, Reader, Writer, Socket etc. These classes represent a particular group; e.g., Reader and Writer classes are for Input/Output operation etc. So, Sun has subcategorized the java package into subpackages such as lang, net, io etc. and put the Input/Output related classes in the io package, and so on. The following example illustrates the subpackages. Pre-defined subpackage : java.lang.*; User-defined subpackage: pack.sample.subpack;
25
8.5.1 Creating Packages If the class or interface is created inside a package, then the declaration of the particular package name should be used. To create a package, first the name of the package is declared using package keyword followed by a package name. Then the class is defined as just a normal class. The general form of package declaration is package package_name1; public class firstclass { …(class definition) }
26
Example Any name can be assigned to the name of the package. The name should satisfy the Java naming rules. According to naming convention, the package name begins with lowercase letters. For example, If two of the classes like Temperature and Humidity are created and grouped into the package called weatherdetails, then these classes should consist of the following statement at the beginning of the each class. For instance, first the class Humidity is created. package weatherdetails; public class Humidity {…} Next , Temperature class is created in the same package. public class Temperature
27
8.5.2 Accessing a Package from Another Package
There are three ways to access a package from outside the package. 1. import package.*; // importing all the classes in package 2. import package.classname; // import the particular class 3. Fully qualified name- instead of using import statement, fully qualified name of the class has been given in the place. Example: class A extends java.util.Scanner
28
1) Using packagename.* Using package.*, all the classes and interfaces of this package will be accessible, but not subpackages. The import keyword is used to make the classes and interface of another package accessible to the current package. The following example illustrates this. Class A is created within the package pack1. // A.java package pack1; public class A { public void msg(){ System.out.println(“Hello”);} } // B.java package pack2; import pack1.*; class B public static void main(String args[]) A obj = new A(); obj.msg(); Output : Hello
29
2) Using packagename.classname
The second approach is using import package.classname. Only the declared classes of this package will be accessible. The following example shows that Class A is created in pack1 package. class B is created in pack2 package. //A.java package pack1; public class A { public void msg(){ System.out.println(“Hello”);} } //B.java package pack2; import pack1.A; class B { public static void main(String args[]) A obj = new A(); obj.msg(); Output : Hello
30
3) Using fully qualified name
The fully qualified class name of the package will be specified in-line without using the import keyword. Now there is no need to import. But it is necessary to use the fully qualified name every time one accesses the class or interface. It is generally used when two packages have the same class name; e.g., java.util and java.sql packages contain Date class. In the following example, class A is created in pack1 package and class B is in pack2 package. // A.java package pack1; public class A { public void msg(){ System.out.println(“Hello”);} } // B.java package pack2; class B { public static void main(String args[]) pack1.A obj = new pack1.A(); //using fully qualified name obj.msg(); } Output : Hello
31
8.6 Create and Access Packages in Netbeans IDE
The procedure for creating and using a user-defined package weatherdetails will be discussed in detail with appropriate examples. Steps to create package and classes in NetBeans IDE 1. Go to File->new project, a New Project dialog box will open. 2. Choose Java under Categories and Java Application under Projects, then click Next.
32
3. Give a name for the project (Weatherdetails in this case) and the location is chosen and displayed either by default or browsing to the desired location.
33
4. Click the Finish button. 5
4. Click the Finish button. 5. Now the main class is created with the package name weatherdetails and it will appear on the screen as shown in the following image. See below on the left of Project window category, the project named as Weather- Details has opened. See that the User-defined package is automatically created with the project name (as package name weatherdetails in this case) with lowercase letters.
34
Suppose one more class is created in another package called forecast, then to create another package n the same project, the steps are given below. 1. Right click on the Source packages, choose New-> Java Package
35
2. A dialog box will open. Type the name of the new package, as shown in the following image. Java_
36
3. Click the Finish button. 4
3. Click the Finish button. 4. A new package forecast has been created under Source packages as shown below. Now, AnnualHumidity and Temperature classes can be created inside the forecast package.
37
Program 8.5 lists the code for AnnualHumudity class.
//AnnualHumudity.java package forecast; //package declaration public class AnnualHumidity // class definition { double avghumidity_chennai=70; double avghumidity_bengaluru=65; double avghumidity_hyderabad=56; double avghumidity_thiruvananthapuram=78; } This class contains data members as average humidity of four cities. Next, Temperature class is created in the same package forecast, the code for which is given in Program 8.6
38
Program 8.6 Program 8.7 Output 8.7 Celsius to Fahrenheit:82.4
package forecast; //package declaration public class Temperature extends AnnualHumidity { double degree; public double FahrenheitToCelsius(double degree) { return (degree - 32 * 5 / 9); } public double CelsiusToFahrenheit(double degree) { return (degree * 9 / ); public void print_humidity() { System.out.println(“Humidity level in Chennai:”+avghumidity_chennai); System.out.println(“Humidity level in Bengaluru:”+avghumidity_bengaluru); System.out.println(“Humidity level in Hyderabad:”+avghumidity_hyderabad); System.out.println(“Humidity level in Thiruvananthapuram:”+avghumidity_ thiruvananthapuram); } } package weatherdetails; import forecast.Temperature; public class Main { public static void main(String[] args) Temperature t=new Temperature(); System.out.println(“Celsius to Fahrenheit:”+t. CelsiusToFahrenheit(29)); System.out. println(“Fahrenheit to Celsius:”+t. FahrenheitToCelsius(45)); t.print_humidity(); } Output 8.7 Celsius to Fahrenheit:82.4 Fahrenheit to Celsius:28.0 Humidity level in Chennai:70.0 Humidity level in Bengaluru:65.0 Humidity level in Hyderabad:56.0 Humidity level in Thiruvananthapuram:78.0
39
Output 8.7 in Netbeans IDE
40
Multiple Packages with Identical Class Names
When there is a requirement to create multiple packages that contain classes with the same name in different packages, there is a problem of ambiguity in reference to the particular class in which these classes are accessed. This can be solved by referencing the classes which contain the same class name in a different package using the fully qualified class name in the object creation statement. For instance, Package pack1 contains Student class Package pack2 contain Student class In Package pack3, these Student classes are to be accessed. But in using the normal way of creating an object for this class like Student s1= new Student();
41
Multiple Packages with Identical Class Names (Contd.)
The statement throws an error message like the reference to Student class is ambiguous, because of the same class name. The compiler gets confused as to which Student class is to be invoked. To solve this problem, the fully qualified package with its class name is given during object creation. For instance, pack1.Student s1=new pack1.Student(); pack2.Student s2=new pack2.Student(); Now, it is clear that the statement of object for each student class with its package name is given in the object initialization. Program 8.8 demonstrates this concept.
42
Program 8.8 //Teacher.java package pack1; public class Teacher {
1. Create Student.java file in the package pack1. Marks is another non-public class within the Student class. //Student.java package pack1; public class Student { String name; String department; public Student(String na,String de) { name=na; department=de; } public void display() { System.out.println(“Name of the student:”+name); System.out.println(“Name of the Department:”+department); } } class Marks { int total; void displaymark() System.out.println(“Total marks:”+total); } 2.Create Teacher.java file in the same package pack1. //Teacher.java package pack1; public class Teacher { String name; String department; public Teacher(String na,String de) name=na; department=de; } public void display() System.out.println(“Name of the staff:”+name); System.out.println(“Name of the Department:”+department);
43
Program 8.8 (Contd.) 3.Create another package called pack2. And then create Student.java file package pack2. Student.java package pack2; public class Student { String name; String department; public Student(String na,String de) name=na; department=de; } public void display() System.out.println(“Name of the student:”+name); System.out.println(“Name of the Department:”+department); 4. Create Course.java in the package pack2. //Course.java package pack2; public class Course { String cname; String duration; public Course(String na,String de) cname=na; duration=de; } public void display() System.out.println(“Name of the course:”+cname); System.out.println(“Duration of the course:”+duration);
44
Program 8.8 (Contd.) 5. Create another package called pack3. Create the main method class PrintDetails. java in Package pack3. //PrintDetails.java package pack3; import pack1.*; import pack2.*; public class Printdetails { public static void main(String args[]) pack1.Student s2=new pack1.Student(“Joel”,”Computer Science”); s2.display(); pack2.Student s3=new pack2.Student(“farhan”,” Computer Science “); s3.display(); Teacher t1=new Teacher(“Ajay”,”Computer science”); Table 1 display(); Course c1=new Course(“B.Sc”,”3 yrs”); c1.display(); } Output 8.8 Name of the student:Joel Name of the Department:Computer Science Name of the student:farhan Name of the staff:Ajay Name of the Department:Computer science Name of the course:B.Sc Duration of the course:3 yrs
45
8.7 Static Import and Package Class
The static import feature facilitates the programmer to access any static member of a class directly. There is no need to qualify it by its class name. The advantage of static import is that less coding required if accessing any static member of a class frequently. The disadvantage of static import is that if the static import feature is overused, then it makes the program unreadable and unmanageable. Program 8.9 illustrates this concept. Program 8.9 import static java.lang.System.*; class StaticImportExample { public static void main(String args[]) out.println(“Hello”);//no need of System.out out.println(“Java”); } Output 8.9 Hello Java
46
Difference between import and static import
Import allows the Java programmer to access classes of a package without package qualification. The static import feature allows access to the static members of a class without the class qualification. Import provides accessibility to classes and interfaces whereas static import provides accessibility to static members of the class. Package Class The package class provides methods to get information about the specifications and implementation of a package. It provides methods such as getName(), getImplementationTitle(), getImplementation-Vendor(), getImplementationVersion() etc. In Program 8.10, the details of java.lang package are printed, by invoking the methods of the package class.
47
Program 8.10 Output 8.10 package name: java.lang
class PackageInfo { public static void main(String args[]) Package p=Package.getPackage(“java.lang”); System.out.println(“package name: “+p.getName()); System.out.println(“Specification Title: “+p. getSpecificationTitle()); System.out.println(“Specification Vendor: “+p. getSpecificationVendor()); System.out.println(“Specification Version: “+p. getSpecificationVersion()); System.out.println(“Implementation Title: “+p. getImplementationTitle()); System.out.println(“Implementation Vendor: “+p. getImplementationVendor()); System.out.println(“Implementation Version: “+p. getImplementationVersion()); System.out.println(“Is sealed: “+p.isSealed()); } Output 8.10 package name: java.lang Specification Title: Java Platform API Specification Specification Vendor: Sun Microsystems, Inc. Specification Version: 1.6 Implementation Title: Java Runtime Environment Implementation Vendor: Sun Implementation Version: 1.6.0_06 Is sealed: false
48
8.8 Access Specifiers Modifiers are keywords that are added to class definition to change their meaning. Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers Java provides a number of access modifiers to set access levels for classes, variables, methods, and constructors. The four access levels are: Visible to the package, the default. No modifiers are needed. Visible to the class only (private). Visible to the world (public). Visible to the package and all subclasses (protected).
49
Access Specifiers (Contd.)
Default Access Modifier – No Keyword The default access modifier does not explicitly declare an access modifier for a class, field, method, etc. A variable or method declared without any access modifier is available to any other class in the same package. For example, variables and methods can be declared without any modifiers. String name = “Hello java”; boolean isDigit() { return true; } Private Access Specifier – Private Methods, variables, and constructors that are declared private can only be accessed within the declared class itself. Private access modifier is the most restrictive access level. Classes and interfaces cannot be private. public class Circle { private int r; public double getArea() { return (3.14*r*r); } public void setArea(int r) { this.r = r; } }
50
Access Specifiers (Contd.)
Public Access Modifier – Public A class, method, constructor, interface, etc. can be declared public and accessed from any other class. Therefore, fields, methods, blocks declared inside a public class can be accessed from any class belonging to the Java Universe. public class Details { public void getdata() System.out.println(“hello”); } Protected Access Modifier – Protected Variables, methods, and constructors which are declared as protected in a superclass can be accessed only by the subclasses in other package or any class that forms part of the protected member's class. The protected access modifier cannot be applied to class and interfaces. Methods and fields can be declared as protected, provided these are not in an interface. class Cricket { protected String Matchcommentator(String sp) // method definition }
51
Access Control for Inheritance
The following rules are enforced for the subclass methods: Methods declared public in a superclass must also be public in all subclasses. Methods declared protected in a superclass must either be protected or public in subclasses; they cannot be private. Methods declared private are not inherited at all, so there is no rule for them.
52
Java Non-access Modifiers
Java provides a number of non-access modifiers to achieve many other functionalities. static: The static modifier is for creating class methods and variables. This has been demonstrated in Chapter, Classes and Objects, final: The final modifier is for finalizing the implementations of classes, methods, and variables. That means the subclass cannot access the final class. This has been discussed in the Chapter 7 on Inheritance. abstract: The abstract modifier is for creating abstract classes and methods. This has been discussed in the chapter on Inheritance. synchronized: The synchronized and volatile modifiers are used for threads. These will be discussed in Chapter 10 on Multithreading.
53
End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.