• 【笔记】Eclipse and Java for Total Beginners—002


    Lesson 02 – Add Methods To Class

    • Introduce Eclipse Views and Perspectives
    • Introduce Eclipse user interface – drag / drop, cnntext menus, help
    • Add get and set methods to Person class

    1. 自动提示或补充标识符。

        英文版的系统用Ctrl+Space, 中文版的系统用Alt+/。

    2. Parameters and Fields.

    3. this

        this = the current object

    4. Class members

        1> Fields for data.

        2> Constructors to create objects.

        3> Methods. e.g.. getters , setters.

    1 package org.totoalbeginner.tutorial;
    2
    3  public class Person {
    4
    5 // fields
    6   private String name; // name of the person
    7   private int maximumBooks; // most books the person can check out
    8
    9 // constructors
    10   public Person() {
    11 name = "unknown name";
    12 maximumBooks = 3;
    13 }
    14
    15 // methods
    16   public String getName() {
    17 return name;
    18 }
    19
    20 public void setName(String anyName) {
    21 name = anyName;
    22 }
    23
    24 public int getMaximumBooks() {
    25 return maximumBooks;
    26 }
    27
    28 public void setMaximumBooks(int maximumBooks) {
    29 this.maximumBooks = maximumBooks;
    30 }
    31
    32
    33
    34 }

  • 相关阅读:
    django 母版与继承
    django 模板系统
    及时从数据库中取得数据填放进Form表单的多选框中
    django 自带的验证功能
    django Form表单
    AJAX 操作
    django 中间件
    JVM-crash查看hs_err_pid.log日志
    java-log4j日志打印
    tomcat 闪退问题排查
  • 原文地址:https://www.cnblogs.com/halflife/p/2076409.html
Copyright © 2020-2023  润新知