JavaFX in simple and Simple (v.) Classes and objects

Source: Internet
Author: User
Tags abstract inheritance integer

Definition of a class

1, with the variables and functions, they and to a piece is not a class?

class People {
var name: String;
var age: Integer;
}
class Hello {
var people: People;
function Greeting() {
println("Hello {people.name} ,You are {people.age} years old.");
}
}

Second, abstract classes and interfaces

1. Abstract classes are decorated with the abstract keyword

abstract class People {
var name: String;
var age: Integer;
}

Abstract classes, like other object-oriented languages, cannot create instances.

2, there is no interface in JavaFX, but can directly use the interface in Java

interface IHello{
void Greeting();
}

Ii. Succession of classes

1, with the extends keyword from another class to inherit

class Man extends People{
var sex:Boolean;

}

2, from the abstract class or interface inheritance, also with the extends keyword, the interface method must be overloaded, with the override keyword

class Hello  extends IHello{
var people: People;
override function Greeting():Void {
println("Hello {people.name} ,You are {people.age} years old.");
}
}

3, JavaFX can be multiple inheritance, that is, inheriting multiple classes and multiple interfaces

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.