(28.218.81608.81609.81613.83566.81816.83767.83846)

1 1.new operator creates an instance of a userdefined object type or an instance of a builtin object with a constructor. Creating a userdefined object requires two steps: 1.The object type is defined by writing functions. 2.Create an object instance by new. When the code new Foo (...) executes, there will be the following: 1.A new object inherited from the Foo.prototype is created. 2.The constructor Foo is invoked using the specified parameter, and this is bound to the newly created object. New Foo is equivalent to new Foo (), that is, no parameter list is specified, and Foo does not have any parameter calls. 3.The object returned by the constructor is the result of the new expression. If the constructor does not explicitly return an object, the object created by step 1 is used. (in general, the constructor does not return the value, but the user can select the active return object to cover the normal object creation step). 2. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package javaapplication1; /** * * @author 张枫 */ public class JavaApplication1 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } } public class Account { private String name; Private double balbance; public Account(String name,double balance) { this.name=name; if(balance>0.0) this.balance=balance; } publice void deposit(double depositAmount) { if (depositAmount>0.0) balance=banance+depositAmount; } public double getBalance() { return balbance; } public void setName(String name) { this.name=name; } public String getName() { return name; } }

group status

👤 group joined: 0 ⏳ group pending: 0 🚫 group blocked: 0

ALL > Computer and Education > courses > university courses > undergraduate courses > Java Programming (2018 English) > home_work > > > (28.218.81608.81609.81613.83566.81816.83767.83846)

Sub Domains (0)