Get the App
SLTechnology News&Howtos  ›  Development  › 

How to simulate object-oriented java code with EXT

Shulou Source: shulou.com Published: 2022-06-02 12:44:33 09月14日 Update

This article will explain in detail how to use EXT to simulate object-oriented java code, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Recently began to contact the AJAX framework-EXT, after learning, but also to record their own experience, see below.

1 、 namespace

EXT organizes class definitions in namespaces, just like the namespace of c # or the package of java. For example, define the namespace of the pojo class:

Ext.namespace ("Ext.domain"); JAVA code comparison: package Ext.domain

2. Class definition

As with javascript, use function to define classes (but here, the constructor is not described)

The code is as follows:

EXt.domain.Person = function () {}

3. Class member variable definition

You can use prototype to define member variables for a class, which, since prototype, is non-static. Ext.apply is a static method provided by the EXT framework that completes this definition.

The code is as follows:

Ext.apply (Ext.domain.Person.prototype, {name: "Zhang San"}); JAVA code comparison: private String name = "Zhang San"; public void setName (String name) {this.name = name;} public String getName () {return this.name;}

4. Class instance method definition

The code is as follows:

Ext.apply (Ext.domain.Person.prototype, {getDetails: function () {alert ("name: {0}, age {1}", this.name,this.age);}})

5. Class static method

The code is as follows:

Ext.domain.Person.getDetails = function (_ name,_age) {var _ person = new Ext.domain.Person (); _ person.name = _ name; _ person.age = _ age; alert (String.format ("name: {0}, age {1}", _ person.name,_person.age))

As you can see, you can use EXT to simulate object-oriented java code and become familiar with Java code.

On how to use EXT to simulate object-oriented java code is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Code object method static content variable name age member article more framework knowledge space article Zhang San good function example is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information MySQL macOS Linux