Interface: Characteristics of common behaviors (methods) of different things in the real world
is a special class, interface
modifier interface interface name {
//property--constant
//method--abstract method
}
All methods in the interface are abstract methods.
Attribute: public static final
Method: public abstract
1. Cannot be instantiated;
2. Subclass implements the interface. The subclass must implement all methods in the interface before it can create an object
3. Subclasses can implement multiple interfaces, and subclasses need interface method implementations to create objects
Application methods:
1. Abstract class --implements---》Interface;
Concrete class---extends --Abstract class;
2. Concrete class --extends--Abstract class---implements---》(Multiple) interfaces;
Class--Single inheritance--Class;
Class--Multiple implementations --Interface;
Interface--Inheritance--Interface;
interface a(); Interface is a special class
interface b();
interface c extends b,a{}
public class testShirt {
public static void main(String[] args){
Frock s = new Shirt();
s.toString();
Clothing c = new Shirt();
c.calcArea();
}
}
interface Clothing{ //Interface
public static final int size = 1;
public abstract void calcArea();
public abstract void getColor();
public abstract void getDate();
}
abstract class Frock{ //Abstract class inherits abstract method
public static final String color = "red";
public String toString(){
return color;
}
}
class Shirt extends Frock implements Clothing {//The concrete class inherits the abstract class and implements the interface
/*public abstract void calcArea();
public abstract void getColor();
public abstract void getDate();
public static final int size = 1;
public static final String color = "red";*/
int age;
public String toString(){
return super. toString()+age;
}
public void calcArea(){
System.out.println("....eat1");
}
public void getColor(){
System.out .println("....eat2");
}
public void getDate(){
System.out.println("....eat3");
}
}
Enumeration:
An enumeration is a special j class that defines a limited number of exhaustible data sets
Format:
modifier enum enumeration class name {
//data
}
get Data: class name.data
class test2 {
public static void main(String[] args){
Signal[] s = Signal.value();
Signal.red ;
} Signal.Green;
}
enum Signal{
red,Green,bule
}
Package (package): Tell the compiler which package the current class is in
package..Class name*; // Multiple paths can be written;
The names of each part of the package name are preferably lowercase letters;
The name of the class is also called the qualified name of the class;
Organization type. Company name. Project name. Function module
com.oracle.ucloud .view
import: Tell the compiler which package other classes used in the current class are located in;
import package name. Sub-package name;
Compile with package:
java -d .Location source file.java
jar Packaging
1. Create temporary file Main-Class: com.bbb.TestAbstractInterface /
2. Create jar file jar cmf temp.txt Person.jar ./
3. Execute file java -jar myprogram.jar

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.