`

The Java constructor and overload

阅读更多
函数的分类:普通方法(original way)、构造方法(construct way)、抽象方法(abstract way)

The java constructor:(1)only use when a class need to be constructed
                     (2)the name of way should be same as the class's name
                     (3)needn't write a return value but it must return an address of
                        the way in the RAM.
its effect is to build a class,only be used when build a class
fundamental form :access authority  class name(){}
eg.
public class defend{
	String name;
	int blood;

	public void setName(String n){
 	name=n;
	}

	public String getName(){
	return name;
	}
	
	public void setBlood(int m){
	blood=m;
	}

	public int getBlood(){
		return blood;
	}
	public void action(attend d){
	int b = d.getBlood();
	b--;
	d.setBlood(b);
	System.out.println(name+"攻击"+d.getName()+","+d.getName()+"的剩余血量为"+d.getBlood());
	
	}
}

overload
the names are same but parameters' numeber,type,the reorder,one of the three isn't
same .It is the other function.
分享到:
评论

相关推荐

    java反射之Constructor

    本文档时关于Java的反射的一个组件Constructor的描述和讲解

    Java自定义异常案例--ExceptionManager(java源码)

    * Show the information in a dialog which has the specified title and belongs to the * specified component. * * @param parent The component cause the exception. * @param title The title of ...

    Java反射之Constructor、Method、Field使用及说明

    附件是自己总结在编程过程中所遇到的关于反射的内容,主要是详细的描述了关于Constructor、Mehod、Field和Class类的内容

    反射之操作Constructor 构造方法类分析.md

    反射之操作Constructor 构造方法类分析.md

    Java邮件开发Fundamentals of the JavaMail API

    A general familiarity with object-oriented programming concepts and the Java programming language is necessary. The Java language essentials tutorial can help. copyright 1996-2000 Magelang ...

    java实验7.1(CollegeCourse.java)

    Run the example by going to c:\java\lab7 and typing: java ynu/edu/lab7/UseCourse For example, the output could be: The cost of your course is $180.0 there is a $25.00 lab fee. The cost of your ...

    Android代码-Watchface-Constructor

    It offers customization of the following features: Background colors and images Watch hands Placement of watch hands Ambient mode How it works? Pull this repository Build and install weareble ...

    c++实验三、四.pdf

    The class has multiple constructors, including a default constructor and a parameterized constructor. The class also has a function to calculate the area of the circle, a function to display the ...

    Java.EE.7.Essentials

    Method and Constructor Constraint Chapter 12 : Java Transaction User-Managed Transactions Container-Managed Transactions @TransactionScoped Chapter 13 : Java Persistence Entities ...

    java实验6(Person.java)

    Write a constructor that takes a parameter for each of the attributes listed above and sets them within the objects by calling the setter methods listed below. The Person class should have a setter ...

    java面经八股文整理

    构造器Constructor不能被继承,因此不能重写Override,但可以被重载Overload。 Java 语言中的作用域有四种:public、private、protected 和默认(default)。public 修饰的元素可以被所有类访问,private 修饰的...

    Java™ Puzzlers: Traps, Pitfalls, and Corner Cases.chm

    Java™ Puzzlers: Traps, Pitfalls, and Corner Cases.chm,英文版本,chm 格式,大小 1 Mb,作者:Joshua Bloch、Neal Gafter。 内容预览: Chapter 1. Introduction Chapter 2. Expressive Puzzlers Puzzle 1: ...

    Copy Constructors and Assignment Operators终极解释

    There are plenty of good books written on the subject, but I found no clear and concise set of rules on the Internet for those who don't want to understand every nuance of the language—and just want...

    Android代码-pusher-websocket-java

    The Pusher constructor Connecting Reconnecting Disconnecting Listening to connection events Subscribing to channels Public channels Private channels Presence channels The User object Binding and ...

    JavaScript的constructor属性[文].pdf

    JavaScript constructor 属性在类型检查中的应用 在 JavaScript 中,constructor 属性是一种非常有用的工具,可以帮助我们检查变量的类型。Constructor 属性可以帮助我们解决 typeof 函数无法解决的问题,即无法...

    Inside The C++ Object Model 英文版

    oriented programming within C++: constructor semantics, temporary generation, support for encapsulation, inheritance, and "the virtuals"--virtual functions and virtual inheritance. This book shows how...

    Java开发技术大全(500个源代码).

    useConstructor.java 使用构造器 useHideMember_2.java 试图使用隐藏的成员变量 useInner.java 使用内部类 第5章 示例描述:本章学习数组与字符串。 ArrayString.java 字符串数组 assignTwoDime.java 为二维...

    基于JAVa的网上商城项目完整源码.zip

    * Constructor of the object. */ public TestContextParamServlet() { super(); } /** * Destruction of the servlet. */ public void destroy() { super.destroy(); // Just puts "destroy...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Header Files The #define Guard Header File Dependencies Inline Functions The -inl.h Files Function Parameter Ordering Names and Order of Includes Scoping Namespaces Nested Classes Nonmember, Static ...

    实例 c# constructor

    实例 c# constructor

Global site tag (gtag.js) - Google Analytics