Object:
Everything is an object.
Objects include two parts: attributes (nouns and adjectives) and behaviors (verbs).
There is a relationship between objects: derivation, association, dependence.
Class:
An abstraction of many objects of the same category.
A class is also a template used to generate objects. The object is a concrete manifestation of the class.
The three major characteristics of object-oriented: encapsulation, inheritance, and polymorphism.
class 类名{ 访问修饰符 成员变量的定义; 访问修饰符 成员函数(方法)的定义; }
Access modifier: not written by default, private, public.
private, private. Can only be accessed by code in the current class class name {}. {} is out of this class and cannot be accessed.
public, public. Can be accessed within the current class class name {}. It can also be accessed by objects in other locations.
Not written by default, it can be accessed in the current class class name {}. It can also be accessed from other classes in the current package. Out of the current package, you cannot access the
get method and set method
1. get member variable name () method: used to obtain member variables when the member variable is private.
1.set member variable name() method: When the member variable is private, it is used to directly change the member variable.
Instantiation of classes: Use classes to generate objects.
Class name variable name = new class name();
Class name variable name = new constructor;
Constructor:
must be the same as the class Same name.
Cannot have a return type.
is automatically executed. The object new is automatically executed when it comes out.
Generally they are public.
First execute the initialization of member variables, and then execute the member function.
If you don’t write it, it will usually be created by the system by default.
public class gou { //成员变量 private String mingZi = "大黄" ; private String zhuRen; //成员函数(方法) public String getMingZi() { return mingZi; } public void setMingZi(String mingZi) { if(mingZi != zhuRen){ this.mingZi = mingZi; } } public void jiaoHuan(){ System.out.println(mingZi+":旺!旺!旺!"); } }
public class home { public static void main(String[] args) { gou a = new gou(); a.setMingZi("小黄"); //用set方法修改名字。 System.out.println("小狗的名字是:"+a.getMingZi()); //用get方法获取名字。 a.jiaoHuan();
Finally displays the overload of the
method:
Function name Same, different parameters (number, type). These two functions form overloading.
Overloading has nothing to do with the function return type number. Overloading is only related to the function name and parameters.
The overloaded function will automatically determine which function to call based on the actual parameters of the call.
In addition to constructors that can be overloaded, ordinary member functions can also be overloaded
The above is the entire content of this article. I hope that the content of this article can bring some help to everyone's study or work. At the same time, I also hope to support the PHP Chinese website!
For more articles on overloading of objects, classes, and methods in Java, please pay attention to the PHP Chinese website!

Bytecodeachievesplatformindependencebybeingexecutedbyavirtualmachine(VM),allowingcodetorunonanyplatformwiththeappropriateVM.Forexample,JavabytecodecanrunonanydevicewithaJVM,enabling"writeonce,runanywhere"functionality.Whilebytecodeoffersenh

Java cannot achieve 100% platform independence, but its platform independence is implemented through JVM and bytecode to ensure that the code runs on different platforms. Specific implementations include: 1. Compilation into bytecode; 2. Interpretation and execution of JVM; 3. Consistency of the standard library. However, JVM implementation differences, operating system and hardware differences, and compatibility of third-party libraries may affect its platform independence.

Java realizes platform independence through "write once, run everywhere" and improves code maintainability: 1. High code reuse and reduces duplicate development; 2. Low maintenance cost, only one modification is required; 3. High team collaboration efficiency is high, convenient for knowledge sharing.

The main challenges facing creating a JVM on a new platform include hardware compatibility, operating system compatibility, and performance optimization. 1. Hardware compatibility: It is necessary to ensure that the JVM can correctly use the processor instruction set of the new platform, such as RISC-V. 2. Operating system compatibility: The JVM needs to correctly call the system API of the new platform, such as Linux. 3. Performance optimization: Performance testing and tuning are required, and the garbage collection strategy is adjusted to adapt to the memory characteristics of the new platform.

JavaFXeffectivelyaddressesplatforminconsistenciesinGUIdevelopmentbyusingaplatform-agnosticscenegraphandCSSstyling.1)Itabstractsplatformspecificsthroughascenegraph,ensuringconsistentrenderingacrossWindows,macOS,andLinux.2)CSSstylingallowsforfine-tunin

JVM works by converting Java code into machine code and managing resources. 1) Class loading: Load the .class file into memory. 2) Runtime data area: manage memory area. 3) Execution engine: interpret or compile execution bytecode. 4) Local method interface: interact with the operating system through JNI.

JVM enables Java to run across platforms. 1) JVM loads, validates and executes bytecode. 2) JVM's work includes class loading, bytecode verification, interpretation execution and memory management. 3) JVM supports advanced features such as dynamic class loading and reflection.

Java applications can run on different operating systems through the following steps: 1) Use File or Paths class to process file paths; 2) Set and obtain environment variables through System.getenv(); 3) Use Maven or Gradle to manage dependencies and test. Java's cross-platform capabilities rely on the JVM's abstraction layer, but still require manual handling of certain operating system-specific features.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
